Our solar system formed over 4 billion years ago from a giant cloud of gas and dust. An explosion from a nearby star created this cloud, and gravity caused the cloud to collapse and spin, forming a dense, hot center that became our Sun. As the cloud flattened, particles stuck together in the outer regions to form planets like Jupiter, while only rocky planets could form near the Sun due to the intense heat. Over time, this process resulted in the current solar system containing the Sun and eight major planets.