Electrocution
I've looked this up for televisions. Some of this information is global for all repairs. The rest is not, but is probably the same for other groups of electrical objects.
Each electrical item has a base break % (B) and repair complexity (C). The sim has a mechanical skill (M). C and M are on a scale of 0-1000. If you have a mechanical skill of 8 that is stored as 800 (well, really 800-899).
The chance of the repair failing is (B * 10 + (C - M)/10)/10 or roughly B + (C - M)/100. The chance of electrocution is 30% of this number (60% if standing in a puddle). Each repair loop the game checks first for electrocution and, if that fails, then checks for repair failure.
As an example, the cheap TV is B = 3, C = 700 so someone with mechanical skill of 0 would have a break chance of 3 + (700 - 0)/10 = 10% and an electrocution chance of 3% (6% if standing in a puddle). Mechanical 10 would have 0% chance of breaking or electrocution.
There is also something about forced breakage but I believe that is for debugging rather than normal play.
Pregnant sims cannot be electrocuted. Other sims suffer -36 to energy, hygiene, comfort, bladder, hunger and fun.
The game then counts the number of motives which have fallen to -90 or below and if the total is 2 or more the sim dies. Unfortunately in an obvious copy-and-paste error, the code checks comfort four times, energy twice and no other motives. So basically if either energy or comfort is -90 or below, the sim dies. I've fixed this in Electrocution Fix.
If the sim doesn't die, electrocution removes a random skill point (weighted so higher skills are more likely to be lost), and then has a 15% chance of starting a fire.