I will present an outline of the major steps in the formation of the Solar System and its evolution towards the current structure. First, the generation of a global dichotomy, with multiple small (~Mars-mass) planetary embryos in the inner part and multi-Earth-mass giant planet cores in the outer part. Second, the onset of a dynamical barrier against the drift of icy particles into the inner system, due to the formation of proto-Jupiter, which allowed the inner solar system to remain ice-depleted despite the disk cooled during its evolution. Third, the inward migration of Jupiter, followed by an outward migration phase at the appearance of Saturn, which might have played a fundamental role in sculpting the terrestrial planet formation region and the asteroid belt. Fourth, the formation of Uranus and Neptune by mutual collisions of proto-cores trapped in resonance with Jupiter and Saturn. Finally, the late dynamical instability of the giant planets, that placed them on their final orbits. This reconstruction of the history of the Solar System will serve as a guideline to discuss which evolutionary phases the most likely to lead to the great diversity observed among extrasolar planetary systems.