Tied to The Law Of Conservation Of Energy, the mechanical energy of a system is conserved in the absence of non-conservative forces (like friction).
This means that changes in the internal energy of the system play no part in this mechanical model.
The First Law Of Thermodynamics generalizes The Law Of Conservation Of Energy and does consider possible changes in internal energy. This law is valid everywhere and applicable to every type of process.
The First Law Of Thermodynamics further gives a connection between the realms of the tiny and the enormous.
Energy is passed between a system and its environment through work done by (or on) the system. This mode of energy exchange brings countable changes in macroscopic or large system variables like pressure, temperature, and volume.
Energy is also transferred by way of heat transfer --- this taking place at the microscopic or tiny level.
For a thermodynamic system changing from a first to a last state where Q units of heat are absorbed or bled away, with W the work done by or on the system, the quantity (Q − W) is measured for various paths connecting the initial and the final equilibrium states. (Q − W) will be found the same for all paths between Initial State and Final State.
Then (Q − W) is completely reckoned by the first and last states of the system. (Q − W) is called the change in internal energy of the system.
Q & W both depend on the particular path, but their difference (Q − W) is path-independent.
Write internal energy as U and state the change in internal energy ΔU as Ulast − Ufirst equal in turn to
(Q − W) [with all quantities having the same energy unit].
ΔU = Ulast − Ufirst = (Q − W) is the statement of The First Law Of Thermodynamics.
Note that Q is positive when heat enters the system and W is positive when work is done by the system.