Some dissipation of energy in the form of heat always accompanies the transformation of energy from one form to another. The transformation of energy is a thermodynamic process, and all such processes are accompanied by a net increase in the entropy of the system through the dissipation of heat.
This empirical statement is called the second law of thermodynamics. It is a general principle that constrains the direction of energy transfer in a system and defines the theoretical maximum energy output that a heat engine can achieve for a given input. This second law asserts that natural processes run in one, irreversible direction: the direction of increasing entropy. Any process that results in a decrease in entropy must involve the addition of more energy than the maximum energy extractable from the system, ultimately leading to net entropy increase. Entropy is defined as heat per common system temperature and always has a fixed sign for natural processes that varies according to convention.
This second law is closely related to the zeroth law of thermodynamics, which states that if two systems are in thermodynamic equilibrium with a third system, the first two systems must also be in equilibrium. The law negates the possibility of perfectly efficient energy exchange, as some energy must always be sacrificed to the coupling between the two systems exchanging energy.