The Solar System began forming about 4.6 billion years ago, or 9 billion years after the Big Bang. Our nebula, which is a cloud of gas and dust collapsed under it’s own gravity and started to spin faster and faster.
In the center of nebula formed a dense clump of matter. The clump of matter is called a protostar. At first the heat generated from it was a result of friction from the matter colliding, then at around 18 million degrees Fahrenheit, nuclear fusion began to occur. Hydrogen atoms fuse together to form helium and this releases energy, or photons. That was how our Sun was formed.
The surrounding disk of gas and dust around the sun combined to form a multitude of smaller objects that would eventually become planets, asteroids and comets.