The theory is that gravity caused the nebula to collapse and eventually started spinning. The accelerating rotation combined with gravity formed a disk. The center of the disk heats up, creating our sun and the solar system. The planets are then formed by accumulating matter from rings in the disk.