If you are preparing to get rid of your iMac, then you will need to follow the instructions in the following Apple article:
What to do before you sell, give away, trade in, or recycle your Mac - Apple Support
However, there is a glaring omission in that article when it comes to an older Mac which may be using an internal Hard Drive or Fusion Drive. The instructions in the Apple article I just linked falsely assumes the Mac is using an internal SSD or has FileVault enabled if using a Mac with an internal Hard Drive or Fusion Drive. If your iMac is using an internal Hard Drive or Fusion Drive, then I would first recommend enabling FileVault and waiting for FileVault to finish the encryption process (it will take hours or days depending on the size & health of the internal Hard Drive). Then you can just perform a simple erase as describe in Apple's instructions using Disk Utility.
If you don't first enable FileVault on a Hard Drive (or Fusion Drive), then you will need to use the "secure erase" option within Disk Utility when performing the erase step so that zeroes are written to the entire Hard Drive or Fusion Drive (actually with a Fusion Drive it would be best to perform a simple erase on the internal physical SSD and the secure erase on the physical Hard Drive portion).
If you only want to erase the system to reinstall macOS for your own personal use, then just follow @Phil0124's advice. As you can see, your question was not entirely clear.....hence the two different suggestions.