The gravitational pull of the Sun keeps the planets in regular orbit.
Even before the planets were born, the matter that created them rotated and spun around the Sun, then kept spinning as a result of the Sun’s explosion into existence.
If it weren’t for the Sun’s gravity, the material would have gone sailing out into space forever.
Instead, the matter accreted into the nine known planets, which continue to rotate around the Sun.