Surprisingly the older iMacs are very upgradeable because of their socketed CPU and MXM GPU. I recently received a free 2010 iMac and was able to upgrade the dual core i3 CPU to a quad core i7, which then boosted the RAM limit to 32GB. I also grabbed an $8 FirePro M4000 MXM GPU from a dell laptop and flashed it for MacOS compatibility .
This old 2010 iMac now has a quad core cpu, 32GB RAM, and a metal capable GPU running the current version of macOS Sonoma. It's running great, and I can essentially run every app on the machine without ever hitting swap, unlike my 8GB MacBook Air.