The best theory we have today, and one that has been supported by the preponderance of data at hand, is that a portion of a primordial interstellar cloud began to contract. As it did, its slight rotation was amplified until the contracting gas formed a rotating, flattened disk orbiting a denser core of gas and dust. The core further contracted to become a protostar containing the lions-share of the mass of the original collapsing cloud. This process took about 10 million years from 'start' to 'finish'. Astronomers have now seen many of these circumstellar disks of material orbiting very young stars, so this part of the theory seems in good shape. TheHubble Space Telescope has photographed dozens of these circumstellar disks in the Orion Nebula, and you should check out their site to see the pictures.
One feature of interstellar clouds which makes direct contact with the known properties of our solar system are dust grains. Astronomers have detected them in dense clouds since the 1960's, and by carefully examining carbonaceous chrondritic meteorites, we know them to be part of the material of the early 'solar nebula'. The solar nebula...now a rotating disk of dust grains and gas...continued to evolve as the sun began to form at its center. The friction in the rotating disk caused temperatures to rise above 1000 K out to about 100 million miles, so that the chemistry of the dust and gas favored silicate materials and not ices. At these temperatures, methane and water...known constituents of molecular interstellar clouds...never got a chance to join into the chemistry, except in the more distant and cooler outskirts of the disk. As a result of the decreasing temperatures from the center to the edge of the disk, a variety of specific chemical domains were set up, each leading to its own set of ratios for the abundances of compounds. The inner solar nebula became rich in silicate, iron, nickel compounds. The outer, cooler disk, became rich in ices of every kind. This imprint still exists in the composition of the inner planets (silicate bodies) and the outer moons of the major planets ( water-rich, icy bodies). Once the chemical composition of the dust grains was adjusted to conform to the ambient temperature regimes in the disk, the next phase commenced.
The next stage, involving planet formation, has not been observed yet. A continuation of the same physical model suggests that the dust grains that are normally found in interstellar clouds, and are quite sticky, begin to build up into centimeter and kilometer-sized bodies which then settle into the mid-plane of the disk. This process may end at this scale unless the hydrodynamical and gas dynamical conditions are just right. Too much turbulance, for example, and the small clumps will collide and break apart, never to form larger bodies. It is thought that gravitational instabilities in such a disk can also hasten the formation of very large bodies. Like a miniature spiral galaxy, the flattened rotating disk was unstable and tended to form a double or multiple-armed pinwheel pattern rotating within the body of the disk. Also during this stage, considerable angular momentum was transferred out of the Sun and into the disk. The Sun contains 99% of the mass of the current solar system, but only 2% of its angular momentum. The best-known method for 'breaking' the Sun is to use magnetic fields. These have been detected in many infant stars, so we know that for other stars like our Sun ( but with ages of less than 10-20 million years) powerful magnetic fields are indeed present. Typical dust grains seen in meteorites and in interstellar space have sizes measured in microns.
To make planets, we have to get the dust and gas to come together into larger bodies. Meteoritic samples tell a very rich and complex story of how this probably happened, and rely on the fact that dust grains are typically very sticky. As they circulate through their local region of the disk, they collide with other grains and for various estimates and models, grow to centimeter sizes in only a few thousand years! Studies of meteorites have also revealed that these growing dust grains formed in rather hostile environments which alternated between periods of hot and cold, and in which tremendous bursts of energy ( lightning?) existed to singe them. These processes only served to make their surfaces even stickier ( partial melting and cold freezing). Because the rotating disk has its own gravitational field, grains precipitated out of the 'atmosphere' of the disk and slowly sank into the mid-plane of the disk, further narrowing the thickness of the planet formation region into a very narrow band...the present Ecliptic plane.
We do not know exactly what process causes matter to make the jump to kilometer-sized and planetessimal-sized bodies. Direct collisions seem the simplest mechanism to build up larger and larger bodies, and the cratering evidence we have from dozens of bodies around the solar system show that very large bodies did indeed exist in great numbers once upon a time. Even gravity itself could have amplified this process. Such a narrow, self-gravitating disk is very unstable, and calculations suggest that it would tend to break up into even smaller clumps and inhomogeneities. The estimated sizes of these clumps is about a few hundred meters to a few kilometers or so...similar to the sizes of the majority of the asteroids in the Asteroid Belt. The number of such bodies in the primitive solar nebula is hard to imagine. All we have to do is look at the surfaces of the inner planets, moons and even the asteroids themselves, to see that an intense period of bombardment occurred by objects of about this size. The density of these bodies in any cubic mile of the nebula must have been very high, because the amount of dust material available in the solar nebula was several percent of the mass of the Sun, and no solar process could eject these centimeter-sized pellets once formed. As for the gas in the nebula...that's another story. We know that sun-like stars go through a T-Tauri phase as their nuclear fires are turning on. This unleashes a tremendous solar wind that washes through the inner solar nebula and scours-out all of the gas. This phase ends about 20 million years after the solar nebula and proto-sun started to form.
The small bodies collided and merged, and it is estimated that it took less than about 100 million years to form a body as large as the Earth. Initially, the planetessimals grew by direct collision, like a tennis ball hitting a basket ball dead-on. But as the body grew in size to over a few hundred kilometers, its own gravity field began to steer surrounding dust and matter into a capture cone so that the planetessimal could sweep-out more material that was simply present along its orbit. Towards the end of this runaway accretion process, larger and larger bodies were available as the solar nebula continued to 'age' and the distribution of body sizes relentlessly got bigger. Although initially the body sizes may have been only a kilometer, by the end of the planet formation process, bodies several hindred, or even thousand kilometers in size may have collided. One of these apparently plowed into the Earth and tore off enough material to form the Moon. A second one may have collided with Venus and tipped its rotation axis; a third one smacked into Mercury and tore off its crustal material leaving only its mantle behind. A fourth one may have tipped Uranus on its side before this planet had formed its own satellite system.
The inner planets formed rather slowly over time, but the outer 'gas giants' followed a different pattern. Once a planet reaches 10-20 times the mass of the Earth, its gravitational field becomes so strong that, in the cooler outer regions of the solar system where gas moves sluggishly, even this gas can be trapped by the growing planet. The planet then grows exponentially. The details are still in dispute, but it does not seem to be too hard to create a Jupiter-sized body in a few tens of millions of years. The discovery of Jupiter-sized planets around other stars tells us that these bodies do not stay put, but probably drift inwards in the solar nebula during formation. Jupiter, for instance, may have formed by the orbit of present-day Saturn, and drifted inwards due to viscous and gravitational forces within the disk. In some disks, these huge bodies could even drift all the way into their star and evaporate! As they move inwards, they would eject any forming planets already present...including proto-Earths!
The composition of these planets, and their atmospheres, depended on where they were in the circumstellar disk, because the inner disk had a temperature of over 1000 K and the outer limits were at 20 K. In the region we call the inner solar system, compounds rich in silicates, iron and nickel would be in thermodynamic equilibrium. In the outer solar system beyond Jupiter, methane, ammonia and water ices would be abundant. This accounts for why the inner planets and asteroid belt are rocky bodies, and why the moons of the outer planets are all giant balls of ices. This 'chemical equilibrium' model is very powerful, and could be used to predict the composition of undetectable planets in other solar systems knowing only their mass and distance from their star. After the T-Tauri phase had removed the free gas within the disk, and blasted away the original atmospheres of the inner planets, new atmospheres outgassed from the planets interiors...setting the stage for interesting surface chemistry. Even cometary bodies colliding with these planets may have unloaded significant quantities of enriched, molecular material...and great quantites of water...but not as much as what would have been outgassed from inside the planets themselves.
For the next billion years, the planets would continue to be bombarded by large asteroids until these free bodies had been completely swept out or ejected from the inner solar system. Today, there still exist pockets of these ancient bodies throughout the solar system...and we must be constantly on the alert for potentially devastating impacts.