How does the compensating resistor act in op amp
The assumption is that the bias currents flowing into or out of the inputs are similar to each other (usually a very good assumption with bipolar op-amps, in which the currents tend to be relatively high). 

So suppose 5uA flows out of each input (typical range of input current for good  amplifiers aimed at high-end audio applications).. and the resistor R1 is 10K, then there would be 50mV at the inverting input assuming the output is not changing. Putting 10K on the non-inverting input means it also will sit at 50mV above ground. If the offset voltage is zero and the input bias currents are the same, then the amplifier will be biased. 

The particular circuit shown is an inverting integrator and adding the resistor does not make a whole lot of difference since the output voltage is dependent on the history of capacitor current and initial conditions. It can make a lot of difference if the circuit is an amplifier or if you short the capacitor to set the integrator initial condition (but then you don't want the resistor, for reasons that should be obvious if you think about it- or, more precisely, the resistor should match the switch 'on' resistance).