How gravitational force is conservative force!???
First of all you need to know what is Conservative Force?
Any force with the property that work done in moving any particle/object from one position to other doesn’t depend upon the path taken but only on the initial and final positions of the object is called conservative force. It means that if a object moves along a circular path and reaches back to its initial position then total work done is zero.
Informally the force which conserves mechanical energy is called conservative force.
Now taking the example of Gravitational Force. Suppose we throw a object of mass ‘m’ upward suppose it goes up to a height h.
then the work done in throwing object in upward direction w1 = -mgh (use ‘-g’ sign convention )
and the work done while returning to the same path w2 = mgh
total work done W = w1 + w2 = -mgh+mgh = 0
Hence, total energy loss will also be zero in this case.
So, Gravitational Force is Conservative Force.
It won’t be the same case if any friction is present, there will be some mechanical energy loss due to friction.
Therefore, friction is a non-conservative force.