The planets of the solar system revolve around the Sun due to the force of its gravitational pull. The elliptical orbit of the planets is a result of the Sun's gravity, which acts to pull the planets closer, balanced by the forward momentum of the planets.
The solar system was formed billions of years ago from a large cloud of gas and dust. As this cloud began to collapse under its own gravity, it formed a spinning disk with the Sun located at its center. The planets were created from this accretion disk, forming from particles that began to accumulate until they merged into planet-sized objects. The newly formed planets retained the same rotational inertia as the accretion disk from which the solar system was formed.
There are two opposing forces that determine the orbit of a planet: planetary inertia and the gravitational pull of the Sun. In order to create a stable orbit, these forces must remain perfectly balanced. The Sun is the most massive object in the solar system, and it has the strongest gravitational pull. Without the Sun's gravity, the forward momentum of the planets would carry them into deep space, just as their sideways momentum keeps the planets from falling inward and being consumed by the Sun.