There are a number of ways to determine the mass of the earth.... many depending on the attraction between heavenly bodies using Newton's or Kepler's laws. Then you might say how can we do that if we don't know the mass of the sun or the moon etc?
We have many artificial satellites that we monitor and have know mass & velocity. Taking that information & using Newton's Gravitational Law or Kepler's third law, the unknown mass (earth) can be calculated. That number has been refined over time and doesn't give the mass down to the exact kilogram, but it is a very close to the actual figure!
So, how satellites (moons, asteroids, artificial satellites) move around other objects in space is governed by those laws!
A footnote: Black Holes, even though not seen, are surmised because galaxies don't necessarily move as Newton's & Kepler's law dictate based on the known visible masses. So, physicists calculate masses of these "Black Holes" based on how the masses around them move!