Astronomers know that our solar system formed about 5 billion years ago from material left over from previous generations of stars. However, beyond that, it gets a little murky.
The prevailing theory is that a nearby supernova explosion compressed a dense cloud of gas and dust until it collapsed in on itself due to its own gravity.
As the cloud condensed, it grew hotter and spun faster. Eventually, the center of the cloud grew so hot it began fusing hydrogen into helium and became the star we lovingly call the Sun.