According to the information provided to define an average density, it is necessary to use the concepts related to mass calculation based on gravitational constants and radius, as well as the calculation of the volume of a sphere.
By definition we know that the mass of a body in this case of the earth is given as a function of

Where,
g= gravitational acceleration
G = Universal gravitational constant
r = radius (earth at this case)
All of this values we have,

Replacing at this equation we have that

The Volume of a Sphere is equal to

Therefore using the relation between mass, volume and density we have that
