Hi there Randomname1936,
If you are unable to use or update this iMac, the steps in this helpful article can resolve what's happening: If an error occurred while updating or installing macOS
If you are still unable to update the Mac using safe mode, macOS Recovery or the other recommendations from that, then create and use a bootable installer next to see if OS X El Capitan will install successfully. This shows how to do this: Create a bootable installer for macOS
If you are still unable to update to OS X El Capitan, contact Apple Support next. They would be the best suited to investigate this issue further and look into your available options.
Cheers!