A relay uses an electrical current to activate a switch.
Two of the pins connect to the coil of wire. A certain amount of voltage and amperage will turn it into an electromagnet, activating the switch, to which the other two pins are attached.
It can be useful if you want to use a small amount of current to switch on a larger one. For example, a low-voltage circuit could be used to trigger something like a 120VAC light bulb.