If you are going to replace that drive yourself you should look at the OWC macsales site and think about perhaps installing a much faster SSD ( Soild State flash menory Drive) into your iMac, instead.
OWC macsales has these and you can call or contact them for more information.
An internal SSD in your iMac will be FAST!
https://eshop.macsales.com/shop/ssd/owc/imac-27-inch/late-2009
If you plan on doing a DIY of your iMac, if you have never did a teardown/reassembly of any computer and, especially, an iMac, you need to be careful.
Lots of different sized fasteners and small fiddly connectors to be careful of.
My replaced hard drive in my late 2009 iMac is doing what yours is doing. Finally dying a slow death after only 6 years!
I couldn't pay for both a new internal SSD and the cost for my local Apple Authorised Service to install it and I didn't want to break into my only work Mac to do a DIY I have never done before, so I went with purchasing and using an external FireWire. enclosed, 480 Gbs storage SSD from OWC macsales.
https://eshop.macsales.com/item/Other%20World%20Computing/MEF3MSSD480/
Running this external SSD from FireWire 800 IS faster than running a standard FW800 mechanical hard drive.
I am amazed how fast my Mac runs from this externall SSD. It is faster than all of my other bootable FireWire connected drives, hands down!
The only issue that I have is that the SSD enclosure doesn't seem powerful enough, even with its own power supply running it, to boot up with all 3 of my other connnected FW800 drives.
I have to disconnect all of my other drives first, boot from the SSD which is really quick and fast, then reconnect my other external drives.
If I leave the drives connected while trying to boot the SSD. I just keep getting the spinning gear forever.
That is the only strange issue I have with this drive.
Once I get everything connected up, again, things just purr along great!