Work done = Force × displacement
We have
Force= mass × acceleration
Due to gravity
F = mg
Displacement equals a body's height when it is above ground level.
So Work done = mg × h
W = mgh
Work done has the same units of energy that is Joules.