What is the purpose of the 10kΩ resistor in this circuit?
It's a pull down resistor, its purpose is to set the voltage of the Arduino input to 0 V when the button is open. It just sets a default voltage value to the connected node.
But, why is such a resistor needed? Well, when the button is open, the voltage is not totally equal to zero due to antenna effects or surrounding components. It is then possible that the Arduino input is triggered for no reason.
Note that the value of pull up or pull down resistors is usually around 10k - 100k. If the value is too low, it's going to draw too much current when the button is closed. If the value is too high, the resistor will behave as an open circuit, making the pull down resistor useless.
As it is widely used in electronics, I recommend you to read some more about this concept.