Do you ever need to drive something with more power than your microcontroller pin can handle? That is where MOSFETs come in. They are digital switches that can handle much more current than a GPIO pin.
Understanding Microcontroller Pin Input/Output Modes
General purpose input/output (GPIO) pins on microcontrollers have various modes for both input and output. Input modes may include pull-up or pull-down resistors, hysteresis, or some combination. Output modes can be push-pull, high-drive or open-drain.