Here's a breakdown of how it happened:
1. The Big Bang: Around 13.8 billion years ago, the universe began with an incredibly rapid expansion from this singularity.
2. Cooling and Formation: As the universe expanded and cooled, the initial energy began to coalesce into subatomic particles, then atoms. Over time, gravity pulled these atoms together to form stars, galaxies, and eventually, our solar system.
3. Stellar Evolution: Our solar system's matter was likely created within earlier generations of stars that lived and died, releasing heavier elements into space.
4. Solar Nebula Formation: This ejected matter then formed a cloud of gas and dust called a solar nebula.
5. Solar System Formation: Gravity within the nebula pulled the material together, eventually leading to the formation of the Sun and the planets we know today.
Important Note: We don't have a complete understanding of the earliest moments of the universe. While we have a lot of evidence for the Big Bang and the subsequent evolution of the universe, there are still many unanswered questions about the initial singularity and the very first moments after the Big Bang.
So, the matter in our solar system, like all matter in the universe, existed in a compressed, dense state within the initial singularity before the Big Bang. It was then released and formed through a complex process of expansion, cooling, and gravitational collapse over billions of years.