Force of gravity for spherical objects of constant density is calculated from 2 masses + 1 distance + a constant.
Before the experiment you can measure the mass of both objects. In the experiment you measure the force and distance to calculate the constant.
The weight either object gives you the force between that object and earth (adjusting for atmospheric buoyancy). Altitude at your location + size and shape of earth gives distance between object and center of earth, you just learned the constant. So you know 4 out of five variables in an equation and can thus calculate the mass of the earth.
Technically that excludes the weight of the atmosphere above your altitude, but you can get that from the air pressure. Similarly the density of the earth isn’t constant but it is very close to symmetrical so you can get a reasonable estimate.