Microcontrollers work without and operating system or with a very small Real-time operating system (RTOS).
A microcontroller just as the Raspberry Pi Pico (RP2040 chip) and a Raspberry Pi running linux (e.g. Raspberry Pi Zero 2 W) are almost the same price — $4 vs $15.
Microcontroller have KB's to MB's of RAM and storage and computers have GB's of RAM and storage.
There is some overlap in how these systems are used but generally if you want to control low-level are hardware with specific time or latency constraints use a microcontroller. If you want to run regular programs (with or without a keyboard and screen) use linux.