Protecting microcontroller digital output pin from ESD, reverse connection, and other possible user error
simulate this circuit &ndash; Schematic created using CircuitLab

Something like this is a starting point. Check the ESD capability of the MCU. To fully protect against ESD you may need to add a TVS and another resistor and pay special attention to the leakage of the TVS relative to R1. 

You will need to debounce the switch in firmware or alter the time constants in conjunction with hysteresis of the input to eliminate multiple counts from bounce.