I think this is essential the same question you have asked in other posts
where you have been given advice to source another mac that you know
can run El Capitan and create a bootable installer there.
If you cannot source another mac to act as a donor then there are other ways to
get an OS installed.
Some more information would be nice.
Do you know which year this mac is from.
Does this iMac have a built in CD/ DVD drive.
Were you given the original install disks.
Were you given a Snow Leopard DVD disk.
If you were given the Snow Leopard DVD install disk you can install that
update it to version 10.6.8 from here,
https://support.apple.com/kb/DL1399?viewlocale=en_US&locale=en_US
After you have updated it to 10.6.8 open the App Store Updates page
install any other updates.
Download El Capitan from this link,
How to get old versions of macOS – Apple Support
Go to Download OS and click on OS X El Capitan 10.11
this downloads InstallMacOSX.dmg to your Downloads folder.
The next section can only be done on a mac that is capable of running El Capitan.
This includes macs that have the potential to run El Capitan but have been upgraded to a newer OS.
A mac that came preinstalled with an OS later than El Capitan will refuse to do the next bit.
When downloaded open to InstallMacOSX.pkg, double-click on
that and an installation window will open, this does not install El Capitan
but converts the InstallMacOSX.pkg to the Install OS X El Capitan.app which
you will find in your Applications folder, it should be 6.2GBs in size.
(If the installation window asks which disk you want to install to, you must pick
the disk that you are booted to at the time. Not any internal or external disk that
you want to eventually install El Capitan on, that is for later.)
To start the installation of El Capitan double click on the Install OS X El Capitan.app.
The copy of the install app self deletes after installing El Capitan, so make sure you keep a copy of the
InstallMacOSX.dmg if you need it in future, or you could just make a copy of the Install OS X El Capitan.app
prior to installing and moving it to an external drive for safe keeping.
It is also possible to create a bootable USB installer disk using the Install OS X El Capitan.app in the Applications
folder and the createinstallmedia command in the Terminal app.
Read the instructions here,
How to create a bootable installer for macOS – Apple Support
If you can't source a donor mac or have access to the Snow Leopard DVD installer
then you may have to resort to trying to get El Capitan installed via Apples Recovery
Servers.
The certificates for several of Apples OS's expired in October 2019, Apple haven’t bothered getting these updated on
their Recovery Servers with valid certificates.
Try this workaround, we are going to set the time and date on your mac to a date previous to the expiry date of the certificates.
Connect your mac to your router via cable, not WiFi
Boot to your Recovery HD, click on Disk Utility press Continue.
Select the Disk i the left hand column (Apple HDD.... or similar) Click on Erase.
Give the Disk a name.
Format: Mac OS X Extended (Journaled)
Scheme: GUID Partition Map
Click Erase
When Done Quit Disk Utility.
Click on Utilities in the menubar select Terminal.
Make sure WiFi is switched off, it can reset the date back to today.
Enter a new date, for example or just copy and paste
sudo date -u 011421002017
press Return
enter your password
press Return
If Terminal returns an error saying sudo : command not found, then try again without sudo.
just enter
date -u 011421002017
press Return
You won't be prompted for a Password if you did not need to use sudo
Once the date has changed you can quit Terminal.
Now try downloading the OS.
Click on Install OS X, press Continue.
If this works then when the OS is installed and booted up you can Open System Preferences> Date & Time
and reset the time back to today.