As a quick circuit this will likely work, however if you are using a switch which lacks precious metal contacts then it may not work reliably in some environments unless you pass mA through the switch. It’s a design task to match the contact type to the application.
The switch is connected directly to the MCU, so if ESD (say from a finger operating the switch) finds its way to the MCU pin then it could cause damage or disrupt the program.
If the switch is some distance away, and particularly if the connections are open to mis-wiring by the user you may wish to add protection against damage and electrical noise. It’s part of the design process to anticipate sub-optimal possibilities and to decide whether to allow a failure (soft or hard failure) or to add protection. For example, you may specify that the switch wires can be connected to +/-15V continuous without damage, but the unit cannot be expected to survive a direct connection to the mains. Or maybe you’d prefer your product didn’t false operate whenever a nearby switch or relay operates. Some of that can be done in firmware but if the noise is too high amplitude it may cause improper operation.
If you look at professional consumer product designs such as automotive or garage door openers you’ll often find that even cheap products have a bunch of added components, because the cost of one field failure can eat up the profits from many, many units that don’t fail. Users will generally find all the wrong ways to wire things up that you can think of, and often a few more. Series resistance, TVS diodes, etc., can be very helpful.