Energy conservation in thermodynamic form
The first law of thermodynamics is conservation of energy: delta U = Q - W, where U is the internal energy of a system, Q is heat added to the system, and W is work done by the system. This simple equation encodes a powerful idea: you can change a system's internal energy either by adding heat (directly) or by doing work on it (compressing a gas, stirring a liquid). Conversely, a system can do work on its surroundings (expanding gas pushing a piston) only by losing internal energy through that work or by shedding heat. There is no way to extract more energy from a system than you put in (no perpetual motion machine of the first kind). The internal energy of an ideal gas depends only on temperature: doubling T means doubling U, regardless of how you heated it (fast or slow, high pressure or low).
Work, heat, and the P-V diagram
In a constant-pressure expansion, a gas does work W = P delta V. On a pressure-volume diagram, work is the area under the curve. For a cyclic process that returns to its starting point, the net work done by the system is the enclosed area. A reversible process that extracts the most work (or requires the least work) is one where the path on a P-V diagram is carefully chosen. Irreversible processes (sudden expansion, friction) lose the opportunity to extract work: a gas expanding freely into a vacuum does no work (W = 0) but spreads out anyway because entropy increases, making the first law delta U = Q (the internal energy drop equals heat lost, with no work output).