To use that new iPhone 8, your iMac needs to be running, at a minimum, OS X 10.10.5 Yosemite or later (your iMac model CAN ONLY be upgraded to and run either Mac OS X 10.11.5 El Capitán OR the very latest macOS High Sierra and you, also, need to update your iTunes version to iTunes 12.7.x.
Before embarking on a major OS upgrade, it would be wise, advisable and very prudent if you have a good, working backup of your current system to an external connected and Mac formatted Flash drive OR externally connected USB, Thunderbolt or FireWire 800, Mac formatted hard drive. Then, use either OS X Time Machine app to backup your entire system to the external drive OR purchase, install and use a data cloning app, like CarbonCopyCloner or SuperDuper, to make an exact and bootable copy (clone) of your entire Mac's internal hard drive. This step is really needed in case something goes wrong with the install of the new OS or you simply do not like the new OS, you have a very easy way/procedure to return your Mac to its former working state.
Then, determine if your Mac meets ALL minimum system install requirements.
To download and install either the free macOS Sierra OR OS X 10.11.5 El Capitán need one of these Macs:
iMac (Mid-2007 or later)
MacBook (13-inch Aluminum, Late 2008), (13-inch, Early 2009 or later)
MacBook Pro (13-inch, Mid-2009 or later),
MacBook Pro (15-inch or 17-inch, Mid/Late 2007 or later)
MacBook Air (Late 2008 or later)
Mac mini (Early 2009 or later)
Mac Pro (Early 2008 or later)
Xserve (Early 2009)
Your Mac also needs:
OS X Mountain Lion, Lion, or Snow Leopard v10.6.8 already installed
2 GB or more of memory (I strongly advise, at least, 4 GBs of RAM or more)
8 GB or more of available space
For upgrading to macOS Sierra/High Sierra, you need to meet these minimum Mac system hardware requirements.
MacBook (Late 2009 or newer)
MacBook Pro (Mid 2010 or newer)
MacBook Air (Late 2010 or newer)
Mac mini (Mid 2010 or newer)
iMac (Late 2009 or newer)
Mac Pro (Mid 2010 or newer)
These Mac hardware models need to be running OS X 10.7.5 Lion or later OS X version to upgrade and install macOS Sierra.
you run any older Mac software from the earlier PowerPC Macs, then none of this software will work with the newer OS X versions (10.7 and onward). OS X Snow Leopard had a magical and invisible PowerPC emulation application, called Rosetta, that worked seamlessly in the background that still allowed older PowerPC coded software to still operate in a Intel CPU Mac.
The use of Rosetta ended with OS X Snow Leopard as the Rosetta application was licensed to Apple, from a software company called Transitive, which got bought out, I believe, by IBM and Appe could no longer secure their rights to continue to use Rosetta in later versions of OS X.
So, you would need to check to see if you have software on your Mac that maybe older than, say, 2006 or older.
Also, check for app compatibilty here.
If you have any commercial antivirus installed and/or hard drive cleaning apps installed on your Mac, like MacKeeper, CleanMyMac, TuneUpMyMac, MacCleanse, etc. now would be a good time to completely uninstall these apps by doing a Google search to learn how to properly uninstall these types of apps.
These types of apps will only cause your Mac issues later after the install of the new OS X version and you will have to completely uninstall these types of apps later.
Once you have determined all of this, you should be able to find the latest versions of OS X by clicking on the Mac App Store icon in the OS X Dock and then login to the Mac App Store using your Apple ID and password.
You can then begin the download and installation process of installing the newer versions of OS X from the Mac App Store.