Before you see in this tutorial how to disable Sleep mode on Mac, you should know that this option is only recommended in temporary situations. For example, when you have a task on your Mac that could be interrupted when the macOS system enters Sleep mode.
Apple does not offer an explicit option on macOS to disable Sleep mode, and if the screen is turned off on the iMac, in the default settings it it will automatically enter Sleep.
How to disable Sleep mode on Mac – Ventura macOS
1. Open System Settings, then to the settings from Display → Advanced, activates the option that prevents the automatic entry into Sleep mode when the display closes. “Prevent automatic sleeping when the display is off”

In the step above you learned how to disable Sleep on Mac when the screen closes.
2. I noticed that although the automatic entry into Sleep mode is disabled when the Mac screen closes, there are applications that suspend their tasks. It is best to disable or increase the time until the screen saver is activated and disable the screen lock.

As I said at the beginning, these settings are only recommended for a limited period of time, if you have tasks that require the Mac to be open for a period of time.
The biggest consequences are high electricity consumption and hardware wear.