How was the solar system formed?
The solar system (and other planetary systems) were formed from a large cloud (nebula) of gas and dust.
The original cloud was somewhat spherical in shape and rotating slowly. Mutual gravity caused the cloud to contract. As it did, it heated up (gravitational potential energy converted to kinetic energy) and began to spin faster (conservation of angular momentum).
Eventually it became more of a disk than a sphere (also conserving angular momentum). The center became the sun while the planets were formed in the outer disk.
There are still some problems with the theory as it does explain why some planets have very tilted rotation axes (e.g., Uranus) as well as other issues.