Joel the solenoid has a coil it it to operate the contacts. When you take away the 12V the current tries to reverse due to inductive kick. The diode shorts or shunts it so that it does not feed back into the circuit.
Thats exactly what an ignition coil does to make a spark plug work on a larger scale, and it does not have the diode to stop it.