What is the purpose of resistor at the input of the OpAmp?
The resistor serves no purpose if the opamp were ideal.  However, ideal opamps are hard to find.  All the ones I've seen have some non-zero input bias current.

When the input bias current is significant relative to the external circuit, then having the same impedance drive both opamp inputs cancels out the offset voltage caused by the input bias current that is common to both inputs.

Bipolar input opamps have significant enough input bias current that it is usually specified broken down into the common and independent parts per input.  

Modern CMOS input opamps have so little input current, and its polarity isn't predictable since it's due to leakage, that usually only its absolute value is specified.  In that case, matching the impedances is less useful, and the worst case error from unmatched impedance is much less to begin with anyway.