Artist's view of a Protoplanetary disk with asteroids, NASA
Wikipedia nicely and expertly summarizes current scientific views in the article on the formation of the Solar system. For your convenience I copy the intro here. The full article gives many details and links to additional resources (emphasis and subtitles in the intro are my additions to the original text.)
"The formation and evolution of the Solar System is estimated to have begun 4.568 billion years ago with the gravitational collapse of a small part of a giant molecular cloud. Most of the collapsing mass collected in the centre, forming the Sun, while the rest flattened into a protoplanetary disk out of which the planets, moons, asteroids, and other small Solar System bodies formed.
This widely accepted model, known as the nebular hypothesis, was first developed in the 18th century by Emanuel Swedenborg, Immanuel Kant, and Pierre-Simon Laplace. Its subsequent development has interwoven a variety of scientific disciplines including astronomy, physics, geology, and planetary science. Since the dawn of the space age in the 1950s and the discovery of extrasolar planets in the 1990s, the model has been both challenged and refined to account for new observations.
The Solar System has evolved considerably since its initial formation. Many moons have formed from circling discs of gas and dust around their parent planets, while other moons are thought to have formed independently and later been captured by their planets. Still others, as the Earth's Moon, may be the result of giant collisions. Collisions between bodies have occurred continually up to the present day and have been central to the evolution of the Solar System. The positions of the planets often shifted, and planets have switched places. This planetary migration now is thought to have been responsible for much of the Solar System's early evolution.
In roughly 5 billion years, the Sun will cool and expand outward to many times its current diameter (becoming a red giant), before casting off its outer layers as a planetary nebula, and leaving behind a stellar remnant known as a white dwarf. In the far distant future, the gravity of passing stars gradually will whittle away at the Sun's retinue of planets. Some planets will be destroyed, others ejected into interstellar space. Ultimately, over the course of trillions of years, it is likely that the Sun will be left with none of the original bodies in orbit around it."