Domestic plugged iMac 2012 into multiple socket gives a little shock
The short answer here is that the outlet isn't grounded/earthed.  It could be that socket or it could be the entire structure (at a minimum).  Also I would get an electrical socket tester and verify your wiring.  If anything is at fault, you run the risk of damaging your equipment to injury or death.

Your best bet is to get an electrician to come in and properly ground your electrical system.

Short of that, I would get a UPS (battery backup) and isolate your iMac from the outlet - this will at least give you a little bit of protection, though it won't do a single thing to protect your iMac in the event of a fault (and this is where it will get expensive).