I still have one like that with a Core2Duo inside from 2007. It got a RAM upgrade and it had its HDD replaces once. Still working great.
I can’t say that of my late 2012 iMac. I gave up on it when, after 4 years of service, it required a video card repair, which basically meant the whole motherboard had to be replaced for over $ 1000, because everything was soldered onto it. That was the moment I built my own rig with state of the art PC components that can easily be replaced seperately.