Gravitational force between an object of mass m and the Earth is given by: F = m g.
We assume that the force is constant over distance.
Gravitational potential energy is the work done against the Earth's gravitational field when the object is displaced by a unit length ie. , 1 meter.
Suppose the object is displaced by h meters. (from a height 0 to height h,
Work done = Force * displacement = m g * h
So this is the potential energy of the mass at height h.
We assume that the force (weight) on the object is not a constant over distance.
R = radius of Earth, h = altitude of object h above Earth's surface.
Newtons laws: F = G M m / x²
work done =
On the surface of Earth, h = 0, d = R,
GM/R^2 = g and PE = - m g R
at an altitude h: (h << R)
Potential energy = - m g R^2 / (R + h) ≈ - m g R (1 - h / R)
≈ - m g R + m g h
so change in potential energy when the object moves up by a height h
≈ m g h