Chemical energy stored by molecules can be released as heat during chemical reactions when a fuel like methane, cooking gas or coal burns in air. The chemical energy may also be used to do mechanical work when a fuel burns in an engine or to provide electrical energy through a galvanic cell like dry cell.
Thus, various forms of energy are interrelated and under certain conditions, these may be transformed from one form into another. The study of these energy transformations forms the subject matter of thermodynamics.
The laws of thermodynamics deal with energy changes of macroscopic systems involving a large number of molecules rather than microscopic systems containing a few molecules.
Thermodynamics is not concerned about how and at what rate these energy transformations are carried out, but is based on initial and final states of a system undergoing the change.
Laws of thermodynamics apply only when a system is in equilibrium or moves from one equilibrium state to another equilibrium state. Macroscopic properties like pressure and temperature do not change with time for a system in equilibrium state.