Newton's first law states that an object will remain at rest or in uniform motion in a straight line unless acted upon by an external force.
The way that this is applied in outer space with the moon and the earth is that when the earth moves around its orbit, the moon is going to orbit along with the sun.
I hope this helps, its not that scientific but I'm not that smart, so sorry about that.