The triac needs a control signal relative to the power line it is controlling. So if the triac is going to switch the L side of the load it needs a control signal relative to mains L.
As such it greatly simplifies the design to use mains L as the "ground" voltage for the electronics. Obviously this means that the electronics are live but that can be dealt with by insulating the control buttons and knobs.
The 22 ohm resistor limits the effect of spikes on the power supply. Without it a fast spike (including a badly-timed connection of the mains power) could cause extreme currents to flow.
The capacitor has a reactance of about 1.8K so it limits the current to about 67mA.
The 1 Megohm resistor ensures that the capacitor is discharged when the mains is disconnected.
The Diodes convert the AC current to DC. We need both diodes as there must be a path for current to flow in the capacitor during both half-cycles of it's AC waveform.
Finally the Zener diode and capacitor control and smooth the output voltage.
This type of power supply does have some drawbacks
- The draw from the supply is basically constant and has to be designed around the maximum load the power supply will run.
- The power factor is terrible. The DC output current available is less than half the RMS AC input current.
But overall for providing a little bit of current at 5V for a control circuit that needs to be mains referenced it's not a terrible option.