Do we need a resistor to discharge capacitor of MOSFETs while connected to MCU?

One good reason is to have this resistor to keep the gate low if the MCU pin is in high impedance state (e.g. during reset or after reset until the port is initialized).

(Otherwise during high impedance state it could act as an antenna and pick up some voltage that turns it on)


During normal operation there is no need for the resistor.

However you may want it to put the FET into a known state during power up and reset. Otherwise on power up before the MCU starts to drive the pin the FET could turn on. This could cause glitches on the output or worst case (and this is very unlikely) depending upon what other current surges happen on startup it could cause the power supplies to brown out and crash the MCU.