Classical mechanics approach to this would be gravitational force as we know
F=GMm/r2 and Centripetal force
In free space we when two things are kept some distance apart they accelarate towards each other (along straight line from center of on body to center of another body) due to force of gravity but if they are under some influence with other bodies they does not get accelarate exactly towards each other(deviation along the path), it causes the dirrection of bodies to change. In this case the planets(cause of relatively small mass).
If this deviation is large body(planet) fly by without any effect. If deviation is small, bigger body continuously change smaller one's direction, thus orbit.
fun Q:why does astronauts on ISS feel 0 gravity when ISS is revolving under earth's gravity?
because they experience gravity but the revolution causes them to free fall, which they feel like 0 gravity.