How have we derived the definition of gravitational potential energy? The gravitational potential energy of an object at a point above the ground is defined as the work done is raising it from the ground to that point against the gravity.
How has this definition been derived? Is this definition derived from the general  definition of potential energy which says - Potential energy is energy which results from position or configuration?
If yes, then how?
Or, has this definition been derived algebraically?
 A: Anything like position,energy,mass etc is defined w.r.t to something. for instance:


*

*Your house's position is defined w.r.t to local landmarks like roadways,big malls etc.

*Mass is defined w.r.t a lump of metal sitting in France


Similar is the case with potential energy. To know the potential somewhere you have to fix a point/line/surface etc. where potential is assumed to be zero. It is however interesting to note that potential energy depends purely on the relative positions of the interacting objects.
Now consider a particle $A$ with mass $M$ kept at origin (note how  all of the co-ordiante system is defined w.r.t A). 
Similarly consider another particle $B$ with mass $m_0$ now we keep this particle B a huge distance away from A assume this distance to be $x$. Now force between B and A will be given by:
$$F = \frac{GMm_0}{x^2}$$
Now since x is very very unimaginably large $x \approx \infty$ we can see that the force becomes unimaginably small $F \approx 0 $. Since the force is very very small the interactions between the individual particles will be very small. And potential energy is basically a measure of how well particles interact with each other. So at a distance far far away the gravitational potential energy is almost equal to zero. Now by defintion of potential energy we have 
$$U_g = work \ done \ in \ bringing \ a \ mass \ from \ \infty (0 \ potential) \to x_0$$
but this definition is tedious and not really useful in our day to day where stuff doesn't usually escape to infinity and therefore this definition is of little practical value
However potential energy too is relative hence for practical and down to earth purposes we use another fixed line which happens to be our earth as a place where potential energy is zero (This is done only to ease calculations). so now potential energy is defined with respect to our ground which is a fixed zero for down to earth objects (Eg: You,me,cockroach,butterflies,elephants etc.) we assume ground to be zero potential and therefore define our potential energy as:

Work done to raise our masses up to a height of h.

For down to earth systems this translates to $mgh$ and our simple definition of gravitational potential energy.
*Disclaimer: All above processes like bring a mass, lift up a mass etc must be done slowly to result in minimum change of kinetic energy
