The gravity of the Sun keeps the planets in their orbits rotating. The same as the Moon orbits the Earth because of the pull of earth's gravity, the earth orbits the Sun because of the pull of the Sun's gravitational pull.
Any questions please feel free to ask. Thanks