What Is the Source of the Sun's Energy?
The sun's energy comes from thermonuclear fusion reactions. Because the sun's gravity is so strong, hydrogen atoms fuse together to form helium. When they do so, they release a tremendous amount of energy.
More than 90 percent of the matter in the universe is hydrogen, and the sun, like all stars, is primarily composed of hydrogen. Due to its high gravity, the forces in the center of the sun are so strong that hydrogen atoms fuse together to form helium.
Aside from hydrogen and a small amount of helium, all elements were formed in stars that have since died out. When the sun begins running low on hydrogen, it will start fusing helium. It will continue creating heavier elements until it is unable to fuse anything else, at which point it will briefly become a red giant before ejecting most of its matter and becoming a ball of carbon roughly the size of Earth but with a far greater mass.
Shortly after the Big Bang, the matter in the universe was almost exclusively hydrogen. Early stars served as factories that created elements; bigger stars created heavier elements than smaller stars. The heaviest elements can only be created by the violent explosions of supernovae. The Earth's sun is not large enough to cause a supernova.