Weird lines and black boxes of all sizes on iMac display
Focusing on one area of the graphics corruption, you can see that the layering effects are being calculated improperly.



While that could be a software glitch or a failure of the GPU, my first check would be to replace the RAM.

That era of hardware started using system RAM to back the GPU and calculate the visible pixels between all the layers (each app draws as if it's the only user of the screen and then the OS composts, animates and renders all visible layers). Normally, when things work, you wouldn't know how the screen gets drawn, but here you can see a problem in one of the steps.

If you are comfortable swapping RAM - you might try removing half the ram and test, then swap the second half, but this is likely something you'll take in for a technician to look at once you have a good backup. 

You could also try reinstalling the OS, but my guess is you would see graphics errors when booted to install DVD or even the built in tests which would confirm it's hardware.