Pretty sure all Intel iMacs can support CPU upgrades, as even the new ones have socketed CPUs. It’s going to be a chore though + your CPU choices are limited. GPU is a complete no, as that’s soldered onto the motherboard unfortunately.
I really hate throwing out electronics - always prefer to try and repair them first, but if any liquid is spilled onto one of these keyboards then it’s most definitely a lost cause. They’re absolutely not repair-friendly at all. It’s certainly possible to open them up but there’s pretty much nothing you can do after that.
There’s no easy way to remove it unfortunately - if it was that easy we’d have stolen iOS devices all over the market. Your only option really is to restore it…