A relay is an electrically operated switch. Many relays use an electromagnet to mechanically operate a switch, but other operating principles are also used, such as solid-state relays. Relays are used where it is necessary to control a circuit by a separate low-power signal, or where several circuits must be controlled by one signal.
Relays work on electromagnetism, When the Relay coil is energized it acts like a magnet and changes the position of a switch. The circuit which powers the coil is completely isolated from the part which switches ON/OFF, This provides electrical isolation. This is the reason we can control a relay using 5V’s from an arduino and the other end of it could be running an 220 to 240V appliance, the 240V end is completely isolated from the 5V arduino circuitry.