To add to orbifold's answer, I'll give a quick repeat of Feynman's version of the conservation of energy argument. This is "d'alembert's priciple" or "the principle of virtual work", and it generalizes to define thermodynamic potentials as well, which include entropy quantities inside.
Suppose you have a bunch of masses on the Earth's surface. Suppose you also have some elevators, and pullies. You are asked to lift some masses and lower other masses, but you are very weak, and you can't lift any of them at all, you can just slide them around (the ground is slippery), put them on elevators, and take them off at different heights.
You can put two equal masses on opposite sides of a pully-elevator system, and then, so long as you lift a mass up by a height h, and lower an equal mass down by an equal height h, you don't need to do any work (colloquially), you just have to give little nudges to get the thing to stop and start at the appropriate height.
If you want to move an object which is twice as heavy, you can use a force doubling machine, like a lever with one arm twice as long as another. By arranging the heavy mass on the short arm, and the light mass on the long arm, you can move the heavy mass down, and the light mass up twice as much without doing any work.
In both these processes, the total mass-times-height is conserved. If you keep the mass-times-height constant at the beginning and at the end, you can always arrange a pully system to move objects from the initial arrangement to the final one.
Suppose now that the gravitational field is varying, so that some places, you have a strong "g" and other places a weak "g". This requires balancing the total force on opposite sides of the elevator, not the total mass. So the general condition that you can move things without effort is that if you move an object which feels a force "F" an amount "d" in the direction of the force is acting, you can use this motion plus a pully system to move another object which feels a force "F'" an amount "d'" against the direction of the force.
This means that for any reversible motion with pullies, levers, and gears
$$\sum_i F_i \cdot d_i = 0 $$
This is the condition under which you don't have to do colloquial work to rearrange the objects. One can take the conserved quantity for these motions to be the sum of the force times the distance for each little motion, and it is additive among different objects, and so long as nothing is moving very fast, if you add up the changes in F dot d for all the objects, it must be zero if you did everything reversibly.
This generalizes to a dynamical situation by adding a quantity of motion which is additively conserved along with F dot d, this quantity is the kinetic energy. You can also go backwards, and start with the kinetic energy idea (which can be motivated by collisions), and rederive the F dot d thing. These are two complementary points of view that fit together to give a coherent picture of kinetic and potential energy.
if you have a static force field on a particle which has the property that along some closed cycle the sum of the force times the little displacements is not zero, then you can use this cycle to lift weights.
The proof is simple: arrange a pully system to lift/lower weights at every point along the cycle in such a way that the F dot d of the weights balances the F dot d of the force. Then take the particle around the loop in the direction where F dot d is net positive, while balancing out the force with the weights. At the end of the day, you lifted some weights and brought the particle back where it started.
This means that a nonconservative force can be used to lift a weight. As you traverse the loop, something must be eaten up out of the nonconservative force field, otherwise it is an inexhaustible source of weight-lifting, and violates the first law of thermodynamics. So eventually, all force fields settle down so that the integral of F dot d is zero along every loop. This is the definition of a conservative force.