Laying out the math (assuming earth is an homogeneous sphere) just in case it's not clear:
F_gravitational = G m1 m2 /r^2
g = G Mass_earth / r_earth^2
Mass_earth = r_earth^2 * g/G
Density_earth = r_earth^2 * g/G / V_earth
Density_earth = 3*g / (4*Pi*G*r_earth)
Prior to Cavendish we already new g and r_earth, just missing G.