Varistors are variable resistors whose resistance will sharply drop when the applied voltage is higher than the threshold voltage.

In the given circuit the varistor is placed parallel to the mains voltage. I may be rated at 275V, like Littelfuse's V275LA10CP for a 230V supply. The datasheet says that it will draw 1mA at minimum 389V, so during normal operation the current will be negligible. If there's a voltage peak of minimum 710V on the mains however, the resistance will drop and the varistor will draw a considerable current (datasheet says up to 25A), so that the energy of the peak will be absorbed by the varistor, and that there's no damage to the circuit.
The energy a varistor can absorb is limited, mainly by its size, but in general they can only handle short peaks.
Selecting varistors is not easy. The curve isn't very sharp, and you can't expect to have zero leakage current at 300V and full clamping at 310V. There's a trade-off between leakage (1mA in the example) and the height of the clamping voltage (710V in the example).