As with every other star on the main sequence, the Sun's energy is a by-product of the thermonuclear reactions occurring in its core. Deep inside the Sun, fusion reactions take place that release large amounts of energy. This energy makes its way through the Sun’s layers through a combination of conduction, convection and radiation. Once at the surface of the Sun, the heat radiates into space, warming the solar system.
The fusion reactions in the core of the Sun are the result of hydrogen atoms forced together under great pressure. When compressed enough, and if the temperature and pressure are high enough, the hydrogen atoms fuse to form a helium atom. This reaction produces the energy that keeps the Sun burning and is similar to the fusion in a nuclear explosion.
The Sun does not have an infinite supply of hydrogen. Eventually all stars exhaust this fuel source. In time, the Sun’s core is likely to collapse under its own weight, causing the temperature and density of the core to increase dramatically. When this happens, the Sun grows very large and becomes a type of star known as a red giant. Once a red giant, the Sun swells dramatically, engulfing the orbits of Mercury, Venus and Earth.