It works with the 2M resistors to condition the signal being applied to the op-amp. If it were a low value, that node would be completely dominated by the resistor divider voltage and the 2M resistors would be irrelevant.
With 125V peak on the input, the 98K/2K divider passes 2/100 of the input, or a 2.5V peak signal. That's 5V peak to peak. The input impedance is approximately 2K (exactly 2K || 98K or 1.96K).
The two 2M resistors bias the op amp input to Vref/2 or 2.5 VDC. Note the Thevinin equivalent of the 2M resistors is a 2.5V source with a 1M source resistance.
With an input resistance of 2K and an output resistance of 1M one can ignore the input resistance. Thus the 5V peak to peak is divided by 1M/2M or it is cut in half to 2.5V peak to peak, riding on the 2.5V bias.
Upper signal is 2.5V - 1.25 = 1.25V
Lower signal is 2.5V + 1.25 = 3.75V
That doesn't quite agree with the graph. To get that one needs to rescale the resistors for a DC level of 1.25V, yet keep the 1M Thevinin resistance.
I leave that calculation as an exorcize for the reader.
I think you get some calculations wrong.
I have simulated the circuit & results are in page 1 of attached pdf.
I have then applied superposition by grounding ac source & saw that, with dc source = 5V,
Vbias = 1.25V (not 2.5V as you have mentioned) & Vth resistance = 500K approx (not 1M as you had mentioned).
Both the above results are in page 2 & 3 of pdf.
1M is used to equal impedance from the "sensor" with impedence of 2M/2M dividers. With equal impedance on both sides, the circuit avarages "sensor's" voltage with 2.5V coming from the divider.
When AC is at +125V, it is 125/50 = 2.5V on the left side of 1M resistor. When mixed with 2.5V from 2M/2M divider, it gives 2.5V.
When AC is at -125V, it is -125/50 = -2.5V on the left side of 1M resistor. When mixed with 2.5V from 2M/2M divider, it gives 0V.
Ernie's explanation is correct, but numbers are wrong.
After seeing all of the monkey motion that was necessary to analyze this simple circuit in that other "toy" simulator , I simmed it using LTSpice.
Note how simply LTSpice finds the transfer function of this circuit.
It seems important to determine what value of V(in) makes V(out) = zero and 5V, because those are the limits of what a voltage follower powered with 5V could follow (assuming a rail-to-rail in/out) opamp.
This is done simply by sweeping V(in) from -300V to 510V in steps of 5V, and then using the cursor placement to ask what are the input voltages that get the output to near 0V and 5V. Results are shown in the cursor box. Note the slight offset...
LTSpice simply does 402 .DC solutions, and plots the node voltages vs the independent simulation variable, namely V(in). What could be simpler...
Here is is again, this time with 2meg resistors...
Also, I reduced the sweep range of V(in) from 120V to 130V, and plotted V(out) and I(R3). Note that for V(in)=125, V(out) is exactly 2.500V and I(R3)=zero...