How does a diode clamping circuit protect against overvoltage and ESD?
You are forgetting that these voltage sources are "ideal". So if your input is 20V directly from a supply, it will always be 20V.

Throw a series resistor in there and you can see how it works. 

I used LTspice to model the circuit.

R1 is the input resistance for some IC pin.

I did a DC sweep from -10V to 10V with 1V increments. 

As you see, as I start to go over 5.7V, R1 only sees ~5.7V.

ESDs are much higher voltage and last only for a brief moment, but this should demonstrate the protection.

When \$V_{pin} &gt; V_{dd}+0.7\$, or when \$V_{pin} &lt; -0.7\$, one of the diodes will begin to conduct. The excess voltage (anything above 5.7V or below -0.7V) gets passed either to ground or back into the supply.