The three laws of thermodynamics govern the transfer and behavior of all matter and energy in the universe as science commonly understands it. Summed up, the first law states that the amount of energy and heat in an isolated system remains constant; no more energy can come from a system than was put into it. This ties into the Law of Conservation of Energy which states that matter and energy cannot be created or destroyed. The second law of thermodynamics is one of the most important underpinnings of nature, responsible for time's arrow and the irreversibility of nature.
No matter how ideal a system may seem to be, there is no such thing as a perfect system. Some energy, whether electrical, thermal or mechanical, will be lost to friction and convert to waste heat. This means that over time the total energy of a system will gradually approach zero unless outside energy is added. The amount of entropy, or disorder, in a system will approach maximum, meaning that no useful work can be done in or by the system because its molecules and particles are too disorganized. The second law of thermodynamics holds that systems tend toward disorder from a more ordered state; an ice cube in a glass of water will melt and warm the surrounding water slightly, putting the two systems in equilibrium.
The second law of thermodynamics overrides the first law; where the first law holds that energy output can never exceed energy input, the second law holds that energy output can never equal energy input due to constant loss of energy and the tendency for systems to approach equilibrium. The less energy a system has, the more entropy is present because it takes energy to restore order and decrease total entropy. When the energy within a system reaches an equilibrium, entropy is at a maximum. For example, although a cup of warm water will cool naturally, it takes constant application of heat energy to keep the water at a warmer temperature.
Cosmologists look to the second law of thermodynamics to create theories about the eventual fate of the universe. The most common theory is that because the universe itself is an isolated thermodynamic system, its entropy will approach maximum as the stars burn out and become black holes. These will eventually evaporate after 100 trillion years, leaving the universe as a sterilized void for the rest of eternity, barring quantum fluctuations.