The work done by the gravitational force acting on an object depends on the product of the weight of the object and its vertical displacement. If an object is moved from a point A to a point B under gravity, the work done by gravity depends on the vertical separation between the two points. It does not depend on the path followed to reach B starting from A. When a force obeys this rule, it is called a conservative force.
Some of the examples of conservative forces are gravitational force, elastic force and electrostatic force.
A conservative force has a property that the work done by a conservative force is independent of path.
The work done by a conservative force on an object is zero when the object moves around a closed path and returns back to its starting point.
The force of friction is a good example of a non-conservative force. A block of mass m is moving on rough horizontal surface with a speed v at the point A. After moving a certain distance along a straight line, the block stops at the point B. The block had a kinetic energy E = ½mv² at the point A.
It has neither kinetic energy nor potential energy at the point B. It has lost all its energy. Work has been done against the frictional force or the force of friction has done negative work on the block. The kinetic energy has changed to thermal energy of the system.