Here's a brief timeline of the process:
1. Solar Nebula: It all started with a massive cloud of gas and dust called a solar nebula. This cloud was mostly hydrogen and helium, with traces of heavier elements.
2. Gravitational Collapse: The cloud began to collapse under its own gravity. As it collapsed, it spun faster and faster, becoming a spinning disk of gas and dust.
3. Protostar Formation: At the center of the disk, the gas and dust became so dense that nuclear fusion ignited, forming the Sun.
4. Planetesimal Formation: In the disk around the young Sun, dust and gas began to clump together to form planetesimals, small rocky bodies.
5. Planetary Accretion: Over millions of years, the planetesimals collided and merged, growing larger and larger until they formed the planets.
While this is a simplified explanation, it gives you a general idea of how the Sun and planets came to be.