Work is the conversion of one form of energy into another form. Thermodynamics is the study of the way that one does work with heat. A very simple device that can convert heat into potential energy is a rubber band. Unlike most other substances, rubber contracts when heated. We can therefore lift an object by heating a rubber band.
Heat is converted into gravitational potential energy.
Energy conservation limits the amount of work we can get out of a certain amount of heat. The first law of thermodynamics state that energy is conserved. D Q - D W. A system can be anything. It is most convenient if it has well defined boundaries. D Q is positive if it is put into the system, negative if it is taken out of the system.