Hello, coopers_mom.
Your generosity toward your friend is commendable. But you might want to rethink giving them this iMac, for the same reason(s) that you feel you no longer want it. While your friend will appreciate your generosity, they won't thank you for the very limited Mac experience you are about to pass along. It is, after all, an outdated, unsupported, vintage computer.
User @GeeZ06 posts good advice above and it's easy to use IF you have the restore DVDs that came with the iMac. Restoring this Mac is going to require that you erase the drive, and then reinstall the Mac OS software. Without the factory DVDs that it shipped with you might find that challenging.
IF you're lucky and can boot this iMac in recovery mode (press Command-R at reboot) then you may be offered a way to reinstall macOS from that startup screen without having to download the OS and create an installer disk. Check and see if the iMac will boot in recovery mode before you do anything further.
If you cannot restart in recovery mode, you'll have to download a compatible macOS and create a bootable installer disk on a USB flash drive. If this iMac is still operational now, you should do that with this Mac before you erase the drive. To do so afterward will require using another Mac that can run that same compatible, old macOS.
The specific model-year of the iMac, early/mid-2009 or late-2009, will dictate what macOS you can/should install. You can find that info by clicking the Apple menu > About This Mac.
Compatible macOS installers can be downloaded here: How to get old versions of macOS - Apple Support