That diode is a flyback diode, sometimes called a snubber diode. You will see these wherever there is an inductor being switched on and off. The characteristic behavior of an inductor is that is opposes changes in current. When the transistor Q1 tries to switch off the inductor inside the relay REL1, the inductor tries to oppose this change in current. It does this by increasing the voltage on it's terminals. If you switch off the inductor really quickly, you will get a huge voltage spike from the inductor (hundreds, possibly even thousands of volts depending on the inductor). This voltage spike is called a transient, flyback, or inductive kick. The diode is there so that when the inductor is switched off, there is a path for the current to flow and dissipate through without producing a voltage spike.
So, yes, you definitely need the diode. Without it you would probably blow up Q1 when you switch off the relay, and possibly damage your Pi.