The Formation of Planetary Systems