Resistor: why?

It is a pulldown resistor. Without the resistor, when the pushbutton is released the arduino input pin is disconnected, leaving it free to pick up noise and return unexpected values. This resistor keeps the value at 0 when the pushbutton is released, but when it is pressed, the arduino pin goes to 1 since it is getting voltage from 5v