I love keeping old Macs on the firing line line but this one is a tough call. The 2012 iMac can run no higher macOS than 10.15 Catalina so that makes spending money questionable at this point, right before a new macOS version Monterrey is released.
I'm wondering if it's possible to install the latest and greatest processor (and more?) and thereby turn this computer into one that will operate like a brand-new one.
I do not see a processor change as a viable option due to cost, uncertainty of success, and the fact the your iMac case is sealed and a bear to work on. And, if the processor is NOT the issue but it turns out instead to be something much more common, you've accomplished nothing. Read on.
What is common? The majority of "Slow iMac" reports here are due to slow mechanical hard drives that were de rigueur in 2012. Unless the computer was ordered with a Fusion drives or a factory solid-state drive (SSD), data transfer speeds were usually under 200MB/sec. My 2017 iMac with factory SSD does 2700MB/sec. That alone will make the computer feel like it is frozen in syrup.
As it is best practice to see what is making your current computer slow so you can make informed decisions, we need performance data that show how both software and hardware issues are affecting your speed. Fortunately there is a safe, secure way to do that.
We can quickly and within the confines of these forums help you determine what issues are at play if you use EtreCheck Pro, available here:
https://etrecheck.com/index
The free version will do nicely for this purpose, although the app is worthy of our financial support.
We can see hard data about drive performance, software issues, and RAM usage. Etrecheck is the development of a long-serving and trusted contributor here expressly for displaying information in these forums to help us help you. It will not reveal any personal or secure information.
Due to forum software limitations, you cannot directly paste the report into a reply here. See this excellent User Tip for how to add the text of the report without garbling the results or having the report truncated:
How to use the Add Text Feature When Post… - Apple Community