Every few hours of computer use the issue appears, sometimes right away, other times it doesn't show until I think the problem finally went away, then it reappears. It started with High Sierra, although I vaguely recall it happening once with Sierra, I think.
I don't remember if I was High Sierra install day or a few days later that the problem became more prevelant. I tried to reinstall high sierra from scratch multiple times to fix the issue, using both the internal HDD & external SSD using internet recovery mode to get a known good copy of High Sierra direct from apple's servers.
I am pretty sure at this point it is the hardware failing, despite the fact that the Apple Service Diagnostics are currently not showing an issue with the graphics card. I expect that many others with the same computer configuration as mine would also have the error, but there is no information online showing it. Others on reddit and other forums have chimed in saying that their _____ mac did that before the computer died completely.
Load on the graphics or CPU does not seem to affect it. Sometimes if I go to full screen mode and back again to windowed mode (or connect an external monitor) the issue will temporarily stop for a bit. There is no consistent way I have discovered to trigger the graphics glitches.
The graphics glitches appear on both the iMac monitor, and an external one, ruing out the iMac display itself. (The screen capture would not show the issue if it was just the iMac's display.)
I've pretty much run out of ideas to try without opening up the computer to replace the graphics card, which as you point out would be stupid expensive.
Right now my plans are to keep using the computer until it either completely dies, or I am in a position to purchase a new computer and sell this one for parts, assuming anyone would want it for that purpose.