Your workstation can affect the air intakes. Even with clean vents, temps will go up. This image was posted here a few years back where the user reported severe overheating symptoms. Note the "space" between the work surface and the air intakes:

When I worked in law enforcement, we called that a "clue!" iMacs need that ~3 inches of clearance.
Also check the air exhaust vent. It is under the stand in the middle of the back panel.

Avoid a bit of bad Apple design re that vent. If you tip the screen fully forward, the "neck" of the stand gets too close to the exhaust vent and reduces its efficiency. Someone reported it here, but I did not believe that could happen until I tested on my iMac. Sure enough, when the screen forward and the vent "pinched," my fans sped up and an aftermarket temps app showed the CPU temps going up fast.
...I've rarely used for the last several years.
Was it plugged in the entire time? If not, the internal backup battery—intended to maintain settings for short periods of service or storage but not months—will run down and the computer will forget important things.
I agree with the other comments; I'd first go with the SMC reset already mentioned.