Let the mass m be at A on the surface of the earth. As the mass is moved upwards; the total distance R involved being large; the acceleration due to gravity does not remain constant. So the force is variable. Hence the work done is calculated by integration.
When the body is at distance ‘x’ from the centre of the earth, i.e. at point L, we have
Fgra = \(\frac{GmM}{x^2}\)
Work done to move the body from a distance x to a distance x + dx or through dx is given by
dW = -Fdx = \(\frac{GmM}{x^2}dx\)
Work done to move the body from A to B is
Negative sign indicates that work is done against the gravitational force of earth.