Approximately 13.8 billion years ago, an interstellar cloud of gas known as the solar nebula collapsed under its own gravity due to some cataclysmic event, such as a supernova. This roughly spherical cloud of cold, low-density gas shrank as gravity pulled everything inward. The cloud’s gravitational potential energy was converted to kinetic energy, which in turn was converted to thermal energy, heating the cloud of gas. The Sun formed in the center, where the temperature was hottest and the density was highest. The cloud rotated faster and faster as it shrank and eventually flattened into a disk. Thus our solar system was born.
The planets formed from the materials swirling around the Sun. Close to the Sun, the temperature was too hot for any of the materials to condense. Beyond a certain distance, called the rock-metal condensation line, rocks and metals were able to condense and clump together to form Mercury, Venus, Earth, and Mars: the terrestrial planets. Further out, temperatures were even cooler, which allowed the asteroid belt to form. Beyond a distance called the frost line, temperatures were cold enough for hydrogen compounds to condense into ice. Small clumps of rock, metal, and ice formed and, with the hydrogen and helium gas they captured, became Jupiter, Saturn, Uranus, and Neptune: the jovian or giant planets. Beyond Neptune, icy comets formed Kuiper belt. At the outermost edge of our solar system, a rough sphere of icy objects formed the Oort Cloud. Most of the material in our solar system remained as hydrogen and helium gas, unable to condense.
The terrestrial planets were formed by a process called accretion. Particles that condensed from the gas of the solar nebula began to stick together and grew larger. Soon they were able to attract other particles through gravity to form planetesimals. Gravitational encounters between planetesimals formed the planets and set their orbits. The jovian planets also started out as planetesimals, but these ones captured some of the hydrogen and helium gas. As they captured gas, they became more massive, which allowed them to gravitationally attract more gas. Therefore, most of the composition of the giant planets is gas rather than condensed rock or metal.
Moons generally formed from material orbiting planets or from objects that became trapped by a planet’s gravity. A major exception is Earth’s moon, which formed from a giant impact between Earth and a huge planetesimal called Theia.
Finally, the majority of the hydrogen and helium gas (that which had never become part of a planet) was cleared from our solar system. The gas was cleared by high-energy radiation and solar wind – a stream of charged particles that the Sun continually blows outward. After this, our solar system became basically what it is today as the terrestrial planets began to form atmospheres and Earth gained its unique characteristics that allowed life to be created.
The Cosmic Perspective: The Solar System by Bennett, Donahue, Schneider, and Voit