Follow this guide to Step 14, then jump down to Step 30 disconnecting the Power button connection iMac Intel 21.5" EMC 2428 Logic Board Replacement Use an Ohm meter to test the button plugging into the cables connector. If it is working correctly (which I suspect it is) then we need to look deeper.
Th power button signal is feed thru SMC on the main logic board which then in turn enables the signal to the power supply to turn it on. This allows SMC to over-ride the power on signal when there is a problem within your system.
I would locate your original Grey CD/DVD's, one will be marked as a diagnostic disk, reboot under it lets see if diagnostics passes. Given the age of the system you might want to replace the PRAM battery as it's about time to replace it. That maybe in fact be your problem.