How dust around a young star self-organised into planets, asteroid belts, gas giants, and moons. The Grand Tack hypothesis, late heavy bombardment, etc.
From Wikipedia
The formation of the Solar System began about 4.6 billion years ago with the gravitational collapse of a small part of a giant molecular cloud. Most of the collapsing mass collected in the center, forming the Sun, while the rest flattened into a protoplanetary disk out of which the planets, moons, asteroids, and other small Solar System bodies formed.