The planets of the solar system maintain their orbits around the Sun due to its gravitational pull. Planetary orbits are determined by two forces: the Sun's gravity pulling them inwards and the inertia of their movement, which drives them outwards.
The motion of the planets around the Sun is a perfect balance between their outward momentum and the gravitational pull of the Sun. Without the Sun to hold the planets in their elliptical orbits, they would travel in a straight line due to perpendicular momentum. The astronomer Copernicus was the first to develop a model of the solar system with the Sun at its center.
The movement of the planets around the Sun was determined 4.6 billion years ago, during the formation of the solar system. The solar system was once a vast cloud of dust and gas that began to collapse under its own weight. As this cloud began to collapse, the conservation of momentum across all of the particles that would eventually make up the solar system created a spinning motion. The Sun was formed at the center of this disk, where density was greatest. As the planets formed, they maintained the same general momentum and direction of spin.