You come to work usually for less than half a year, meaning you expect to have the baby. Since you obviously won't work before and after the baby is born, why come to said state as a foreign worker? Who will take care of the baby? While the judge decided to disqualify the rule, I wonder how the European rules are in this regard for comparison, as I lack more information.
Islamic State blows up tower tombs in Syria's Palmyra (Reuters)
from the article: Israel's High Court blocks state from deporting pregnant foreign workers