What is the function of the resistor in the below circuit?
This is a pull up resistor.
When the switch is open, the resistor sets the MCLR pin at VCC.

Without the resistor the pin would be left floating. The MCLR input is a logic input. Which can be 0 or 1. But in the real world, there is no such things as 0 or 1.

A convention could be defined: 


if the voltage is below Vcc/2 it is considered as a 0.
If the voltage is above Vcc/2 it is considered as a 1.


A problem with this approach arise when the input voltage crosses the threshold. At some point in time, it is at the threshold. And if there is some noise on the signal, the pin could see a 0 or a 1 bouncing very quickly. Imagine that the input is a clock signal and you would see clock edges where you don't want to.

The following approach solves that problem:

There is are two thresholds: Namely Vih and Vil.
A signal is considered as 0 if it is below Vil and a 1 if above Vih.
The two threshold are separated by a grey zone that prevent toggling by added noise (up to a certain level).

The following figure found on the web explains that feature:



The resistor in you schematics is here to make sure that, when the button in not pressed, the voltage at MCLR is above Vih (not in the forbidden region).

But, as @Spehro Pefhany expains in his answer, this is not enough.

A press button is not prefect. When you release it, you may (and you will, actually) see bounces.

This picture, also found on the web shows this:

 

A way to overcome this issue is to "smooth" the output signal using a capacitor as shown in the datasheet of the micro controller. The capacitor would be quickly discharged through the low impedance path of the pressed button, but would take some time to charge though the resistor when the button is open due to bounces. If you choose the right resistor-capacitor pair, you could make sure that it would take longer to the MCLR voltage to cross the Vil that it take to the button to stop bouncing.