I see people have mentioned heat dissipation, and mechanical stress relief, but it is my understanding that these loops are basically for a combination of these two effects: reduction of stress from thermal expansion.
Imagine if the circuit is switched on, the diode starts dissipating power, and warms up. Due to thermal expansion, the diode and the horizontal portions of the leads will try to elongate. However, they cannot, as the ends are anchored to the PCB. The PCB will be at a lower temperature, so the pads will still be the original distance apart. The difference in length must be taken up by bending of the diode leads, the solder joints, and/or the PCB. Repeated temperature cycling caused by powerup/powerdown cycles may eventually result in a fatigue failure.
With the loops in place, any elongation of the diode simply results in the loops getting slightly larger, and the resulting mechanical stresses are considerably reduced.
That is the theory, anyway; I don't know of any quantitative data on the generated stresses. The thermal expansion coefficient of FR4 is likely significantly different to that of the diode, so it may be that, depending on temperature gradients, the PCB actualy grows more than the diode. The loop should work in either case though.