Hi,
First, it appears that you do not have a Time Machine backup. If this is the case, you should create one. To start, you need an external hard drive. Here’s an excellent one sold by Apple: LaCie 2TB Rugged USB-C Portable Hard Drive - Apple. You will also need this cable for the external disk to work with your older iMac. You can then follow the steps in this Apple Support article to setup your Time Machine backup: Back up your Mac with Time Machine - Apple Support.
Also, moving forward, I recommend that you use iCloud in addition to Time Machine to sync all your files and photos to all your Apple devices. Although iCloud is not a "true" backup service, iCloud can also act as an emergency off-site backup, but this is why iCloud should be used in addition to Time Machine. Here are some resources on setting up iCloud for Mac:
After you setup iCloud, turn off "Optimize Mac Storage" in System Preferences > Apple ID/iCloud. That way, all changes made to files in iCloud are also backed up to Time Machine. If you have this setting on due to a limited amount of storage on your Mac, that is fine. Just know changes won't be backed up to Time Machine, only iCloud.
However, reason your iMac is slow is due to the 5400-rpm hard drive. While this hard drive found in your Mac is perfectly suited to light tasks, such as email, web browsing, etc., for more advanced tasks, and for users who want the maximum performance from their Mac, this hard drive does have its limitations. Luckily, you can use an external SSD as your startup disk to run macOS and all your data from that. It will make your Mac 10 to 30 times faster for storage, and in turn, make your entire Mac system much faster. For more info, instructions, and what external SSD to buy, please see: How to Setup and Use an External SSD as your Startup Disk on a Desktop Mac - Apple Community.
Another option I would strongly consider is to replace this Mac with a new Apple Silicon Mac: Mac - Apple. You can also use Apple Trade-In to get credit towards a new Mac: Apple Trade In - Apple.
Hope this helps!
Jack