Until about 4.6 billion years ago, our solar system was a giant cloud. It was made up of gas, dust, and ice. As the cloud whirled around, gravity caused it to shrink. The inner part became the Sun. The outer pieces took shape as the planets.
The Sun formed because heat and pressure within the cloud triggered nuclear fusion. Hydrogen atoms were crushed—or fused—together to form helium atoms. This released huge amounts of energy. The same reaction happens when a hydrogen bomb explodes. Intense gravity keeps these ongoing explosions from ripping the Sun apart.