What´s the purpose of this diode?
From the question below:


  A diode is put in parallel with a relay coil (with opposite polarity)
  to prevent damage to other components when the relay is turned off.


This is called a flyback diode.

See also How to choose a flyback diode for a relay?

See also the comment of Kevin White (in my own words):


The diode prevents current spikes
The problem happens during turn-off