An OS is typically used with an embedded system when you're writing your application directly for the system's hardware, which is an unrealistic proposal. What an OS provides to the application is a number of APIs that abstract away the hardware and functionality implemented using this hardware, such as network communications or video output.
The trade-off here is between convenience and both code size and complexity.
Whereas a bare metal implementation ideally implements only those features it needs, an operating system comes with a task scheduler, along with functionality that the application being run may not ever need. For this reason, it's important to know when to use an OS instead of developing directly ...