Best supported OS is OS X 10.11 El Capitan, at least if you have SSD and 4-6 GB RAM.
macOS 10.12 Sierra and 10.13 High Sierra will also run on it with a patched installer, but some iMac8,1 units have an incompatible WiFi unit. That means under 10.12 and 10.13, if you're unlucky then WiFi won't work, although if you're using Ethernet only, then that doesn't matter.
If you don't need WiFi, or if you happen to be lucky enough to have a compatible WiFi adapter, then I'd recommend 10.13 High Sierra with dosdude1's patch.