Until about 4.6 billion years ago, our solar system was just a big cloud. It was made up of gas, dust, and ice. As the cloud spun around, gravity made it shrink. The inner part became the Sun. The outer pieces became the planets.
Here’s how the Sun formed: Heat and pressure inside the cloud created nuclear fusion. Hydrogen atoms were pushed together. Then they became helium atoms. This released huge amounts of energy. The same thing happens when a hydrogen bomb explodes. These explosions are still happening in the Sun. Strong gravity keeps them from tearing the Sun apart.