Hello,
You present a very interesting situation 😉
I am actually more suspicious that you have an unknown / recently occurring problem in the circuits in your room / house.
At first glance, the fault would appear to be that of the iMac. But, your UPS description would indicate that the problem is not with the computer.
You don't mention the brand of UPS that you use. But, most quality UPS brands have an over-voltage indicator.
For example, if I even try to run any of my Laser Printers from one of my APC UPS units, then I get an alarm telling me that something is wrong. If your iMac even momentarily drew too much power from your UPS, you should have a light and alarm that sound on the UPS.
Note that in my example, there is nothing wrong with my Laser Printers. They just draw more power than the UPS can provide through it's battery circuit. The UPS does not complain if I plug the Laser Printer into the Surge Protection Only socket.
But, if your iMac has a fault that causes it to draw too much power, then the UPS should fail to power it and provide you with an audible alarm and flashing light.
The second thing that tells me it most likely is not the computer, is that you claim to have tried it with both the UPS and several "power bars". Now, for the time being, I'll avoid the power bar lecture (you should be using surge protectors not power bars). But, here's the important / relevant detail:
Almost all Power Bars, Surge Protectors, and UPS units have a circuit breaker / over-voltage protection button built-in. That button / breaker / fuse (whatever it is on your unit) should trip well before the circuit in your house.
If the iMac is drawing more power than your house circuit can safely supply (assuming nothing is wrong with your house's circuit), then the breaker on your power bar / UPS should have triggered.
In that case, the breaker on the power bar would have tripped, and your house's circuit would have remained on.
The breaker on the power bar is rated to trip before the level that your house's electrical circuit is supposed to be rated for.
The fact that the breakers on your power bars, surge protectors, and UPS units don't blow tells me that your iMac is operating within the limits that your house circuit should handle.
The weak link appears to be your house circuit.
I would have your wiring investigated, and see if it's either got a problem or wired to be overly sensitive.
It is possible for those types of Arch-Fault protection circuits to trip before they should if there is a problem in the circuit or if they are wired differently. For example, when we were installing ours, there was mention in it's installation sheet that if I certain conditions were met in my wiring, that the circuit would be more sensitive than intended.
Anyway, consider the thoughts mentioned above in relation to the breakers on your power bars and UPS units. And, consider getting the wiring in your house circuit tested and evaluated professionally.
I hope this helps.
Let us know if you have other questions.
P.S., if you'd like, go ahead and click the "Helpful" or "Solved" buttons on any of the posts / replies above if you feel they were helpful or adequately answered your question.