Here's why:
* Gravity is a universal force: It exists between any two objects with mass. The more massive the objects, the stronger the gravitational pull.
* Planets orbit stars: The gravity of the star, which is much more massive than the planet, pulls the planet towards it. This pull keeps the planet from flying off into space.
* Balance of forces: The planet's forward motion (its inertia) and the star's gravitational pull create a balance. This balance results in a curved path, which we call an orbit.
So, while a planet may appear to be just floating in space, it's actually constantly being pulled towards its star by the force of gravity.