when i put it to sleep mode sometimes it wont wake up, instead it shuts off when i press a key to wake it. then it wont turn back on unless i unplug it. this is so annoying! and possibly damageing in some way
Take the back off and look for any bulging capacitors on the motherboard. If you're lucky, there won't be any that are leaking - the motherboard is difficult to remove.
Then remove the power supply (which is easy), and use a flashlight to look at the capacitors in there. You probably have one or two that are leaking. A replacement power supply can be as low as $80.
Post your iMac's serial number and I'll see if you are eligible for the cheap $80 power supply from Apple. Otherwise you have to get it from eBay where it costs $120.
If no capacitors are bulging, then it may be another issue.