The force/owner of the trigger needs to be an active player. Do not select Player 12 as the owner of the trigger. It should be Force 1 (or whichever force is your players)
While this will work, if you want to be truly fair, you should randomize a switch every "loop" to see who gets a unit. Though if you had n players, you'd need n! orderings to check, e.g. if 5 players left in the game, there are 120 unique ways to choose the order in which each player gets a unit. One such ordering is P1, P2, P3, P4 P5. Another is P5, P2, P4, P3, P1. etc. This would be overkill and impractical unless you use a trigger macro framework, e.g.
YATAPI, which can generate TrigEdit triggers via Python.
Or maybe you want to make sure the units get split evenly, e.g. if P1 already has 10 units, P2 has 5 units, and P3 left 7 units, you should give 6 units to P2 and 1 to P1, so they each have 11 units. In the system proposed above, P1 would get 14 units total whereas P2 would have 8 units.
I think the more important thing is perception of fairness when giving out a leaver's units rather than implementation (very simple as shown above with one trigger). Players would want to know why P1 got that unit, etc. (or at least that would be good customer experience I think).
In the most extreme case, you would check which units each player owns and dole out the leaver's units based on which synergize best with their current units. E.g. if P1 has a Protoss Scout and P2 has an Lurker, and P3 left a Defiler, you probably want to give P2 the defiler. This would be a lot of manual work listing out combinations, and if none of those exist, then use the proposal above...
Another example--P1 has a Goliath, P2 has Ultralisk, and P3 left an SCV. Give P1 the SCV, not P2.
None.