If this is an Intel iMac, then I would try creating a bootable Knoppix USB stick in order to check the health of the hard drive. If the hard drive is failing, then it is best to have a professional data recovery service retrieve the files since you usually only get one chance at recovering files from a failing hard drive. Plus macOS and most consumer data recovery utilities are unable to handle the I/O errors produced by a failing hard drive.
I would try using Knoppix v7.x or v.8.6.1 although even v9.x should work. You can use the downloaded Knoppix .iso file as a source for Etcher (Mac, Windows, Linux) to make a bootable Knoppix USB stick. You will need to Option Boot and select the orange icon labeled "EFI" in order to boot Knoppix. The system may appear to be frozen on the Apple boot picker menu while booting Knoppix, so make sure to give Knoppix lots of time to finish booting.
Once booted to the Knoppix desktop, click the "Start" menu icon on the lower left of the Taskbar and navigate to "System --> GSmartControl" (It may be "System Tools --> GSmartControl"). Within the GSmartControl app you need to double-click on the icon for the internal hard drive to access the health information. You will need to click the "View Output" to get the complete report to post here on the forum so I can review it.