The two forces that keep the planets in orbits around the sun are gravitational force and centrifugal force.
The solar system and the planets are made from rotating clouds of gases and matter and that motion still continues. In addition, gravitational forces are exerted by objects on each other. In case of solar system, Sun being the most massive body, exerts gravitational pull on all the planets. The interplay, between Sun's gravitational pull and the centrifugal force of the planets, keep the planets in their orbits and prevents them from falling towards sun or flying out of the orbit. The situation is akin to rotating a string with a mass attached at its end. If after rotating it, we leave the string end, the mass will fly out. We have to exert a force to keep it rotating.
Therefore, its the centrifugal force that counteracts the gravitation pull of sun and keeps the planets in their own orbits.