The solar system formed from a condensed region in a local dust cloud. Nearby supernovae explosions perturbed the equilibrium of the dust cloud over five billion years ago, creating a nugget of density at the center of which our Sun formed. We can observe these clouds today in other regions of the galaxy — they are called Bok globules. Because they are relatively dense dust clouds, Bok globules block out light from objects within and behind them, being a subcategory of dark nebulae. This makes it impossible to directly observe the formation of new stars, although the simulations of astrophysicists give us a good idea of how it works.
Starting out as an irregular cloud, once a center of gravity was established, many of the dust particles in the cloud making up the early solar system would have begun to move into more regular orbits, circling the newborn star as a protoplanetary disc. Within the cloud, large chunks of rock condensed into the planets, which proceeded to sweep their orbits clean of material, integrating it into themselves. Jupiter, being the most massive of the planets, probably did a lot of the sweeping. Many astronomers believe that Jupiter may have in fact made life on Earth possible, by absorbing much of the stray rocks in our solar system, thereby preventing them from impacting other planets such as our own.
After tens or hundreds of millions of years, most of the debris in the solar system was either removed by the planets or moved into stable orbits resonant with those of the planets. That is why most asteroids and space debris are localized in relatively precise bands, such as the main asteroid belt between Mars and Jupiter, and the Kuiper belt beyond the orbit of Neptune.
Astronomers theorize that most solar systems form in pretty much the same way, though for more massive stars, stable orbits are further out. Many stars are also members of binary systems, in which case the stars themselves do more of the debris sweeping than their planetary companions. In recent years, scientists have discovered hundreds of extrasolar planets, and it seems a safe bet that the majority of stars have them. New solar systems are being formed all the time, often catalyzed by supernovae explosions, which seed stellar clouds with heavy elements.