Please don't create multiple threads for the same issue as it can get very confusing.
You iMac can run up to macOS 10.11 El Capitan. Here is an Apple article providing instructions on how to download and "install" El Capitan. Read the article carefully as there are multiple steps that need to be performed.
https://support.apple.com/kb/HT206886
I would suggest creating a bootable macOS 10.11 USB installer just in case something goes wrong during the upgrade. This way you will still have a way of recovering the system more easily.
https://support.apple.com/en-us/HT201372
Make sure to have good backup before upgrading macOS since you could lose access to your data if something unexpected goes wrong during the upgrade. You should have good frequent and regular backups anyway, but definitely make sure to have a current backup before making major system changes.