If an object of mass #m # is on the surface of earth of mass #M # and radius #R# then by the law of universal gravitation the force of gravity on the object is given by
#F_g= (GmM)/R^2......[1]#,
where #G# is the universal gravitational constant.
Again acceleration due to gravity #(g)# is the acceleration with which any object freely falls under the force of gravity. towards the center of the earth.
Now if the mass of the body be # m# then by Newton's laws of motion the gravitational pull on the object will be given by
#F_g="mass" xx "acceleration"=mxxg.......[2]#
So origin of this equation is Newton's laws of motion. Here only acceleration #(g) #is originated from gravitational force.
Comparing equation [1] and [2] we can write
#mg= (GmM)/R^2#
#=>g= (GM)/R^2#
This equation shows how the acceleration due to gravity #(g)# is related with universal gravitational constant #(G)# as well as mass# (M)# and radius #(R)#of the earth