You should still be able to check your Mac’s internal hard drive by restarting it in Recovery mode, opening Disk Utility there, and running First Aid. However, while that should give you a little time to ensure that it’s backed up, when a hard drive is over eight years old and starts to become unreliable you should be prepared for it to suddenly fail.
On this particular iMac, replacing the internal drive isn’t particularly difficult, but does involve separating its display and removing the left speaker. While there are instructions online, you’ll almost certainly want to get this done by an experienced service engineer.