Does this iMac still boot normally or into Safe Mode? If so, then download the macOS 10.11 installer from the link I provided previously, but if you cannot download it because the browser is outdated, then download the installer using any other computer (Mac or Windows) and transfer the .dmg file to this iMac where you run the .pkg file within the mounted .dmg file to extract the real installer.
If this iMac cannot boot at all to the internal drive and extract the installer and you don't have access to another Qualifying Mac (2008 to 2015), then you will need the OS X 10.6 Snow Leopard uprade DVD. Ask you neighbor for it, or you will need to try to find one online to purchase.
If you have access to another Mac running macOS 10.10 to 10.15, then you can try using DiskMaker X to make the bootable macOS USB installer.
These are your options if you want to install macOS.
Edit: This iMac can only run up to macOS 10.11 which is outdated. Safari won't work to access most websites. Even the popular browsers (Firefox and Chromium based browsers) are no longer compatible with macOS 10.11. There may be modified versions of these browsers which to allow older operating systems to access today's websites. Personally I would not spend any money on this iMac for this reason, plus the internal hard drive is likely to be worn out or failing. If the iMac can boot to the internal drive, then you can check the health of the drive using DriveDx. There is other option using a non-Apple OS, but it would require learning a new OS.