The Solar System formed from a cloud of gas, mainly hydrogen and helium, and dust ejected from a supernova. Gravitational forces caused this cloud to collapse and the particles to collect together. As the cloud collapsed it began to spin, this made it turn into a disk. The centre of the disk became the Sun and the rest collected together to form the planets.