Protection? Surge? When driving a relay with a transistor, the electromagnetized core/coil takes a few seconds before the the relay kicks back after you switch off the transistor's forward active mode, which is undesirable when you want to switch a device with precision.
The diode just makes sure this doesn't happen, so when the base current of the transistor goes off, the remaining current in the coil immediately flows into the diode, demagnetizing the coil.
That's why the 'tick-tick' sound of the relay comes out if you activate the transistor briefly when current goes in the base to collector (if npn) for a fraction of a second.
Otherwise, without diodes, the relay goes 'tick........................tick'.