Protoplanet hypothesis is possibly the most broadly held theory about how the solar system formed. The solar system is believed to have formed from a cloud of dust and gas (mostly the hydrogen gas). Due to gravitation, the majority of the material (around 90% or more) became the sun.
The solid material in the the gas cloud clumped into protoplanets that were somewhat like asteroids. The larger clumps were hit by the smaller clumps until we got the 8 planets that we have today. The 4 largest ones were able to retain hydrogen and helium in their atmosphere. Neil