Which force keeps the planets from floating off into space?

Earth’s gravity
the Sun’s gravity
the moon’s gravity
Milky Way’s gravity

All of the above options are correct. The force that keeps the planets from floating off into space is primarily due to the gravitational pull of multiple celestial bodies.

Earth's gravity keeps objects on its surface and also influences the motion of the Moon around the Earth. Similarly, the Sun's gravity keeps the planets, including Earth, in their orbits around it. The Moon's gravity affects the tides on Earth and has a smaller influence on other objects in space. Additionally, the gravity of the entire Milky Way galaxy plays a role in keeping the planets within its gravitational influence. Without the gravitational forces exerted by these celestial bodies, the planets would not remain in their orbits and would indeed float off into space.