When power to inductive loads such as coils and inductors is turned off, there is a sharp voltage spike. The direction of this voltage is opposite to the applied voltage in accordance with Lenz’s Law.
When a current flows through the coil of a relay, the coil gets electromagnetically charged. The energy is stored in the magnetic field around the coil. When the power supply to the coil is interrupted and the current in the coil tends to decrease, the magnetic field discharges causing a surge in the voltage.
The voltage, thus induced, can jump across the contacts of relays connected to the coils. The sparks and arcing produced can affect the life of the contacts. The voltage spikes can also damage electronic components like transistors which may be driving the relay coils.
Freewheel diodes are connected in reverse bias vis-à-vis the supply voltage. Hence, when the voltage spike appears in the opposite direction, they are short-circuited through the diode. The voltage spike is thus short-circuited across the coil. This protects the connected circuits.