It has to do with running a civilized society. A normal person quits with a required warning so the employer can find a replacement. The Residents are supposed to give 30 days warning, but if you have a collective resignation, the employer can't compensate. Considering all the Residents chose this profession knowing the conditions, the judge can't allow mass resignation that will lead to the deaths of innocent people.
But answer this, if the deal signed between the government and the doctors' representatives is so bad that the Residents want to quit, why aren't the representatives named, shamed and blamed? I really don't understand.
Also, in Israel everyone pays the same tuition, but medical education costs millions and social workers and lawyers a fraction of what they pay. Future social workers and lawyers are subsidizing the future doctors. Should Israel universities charge different tuition for different faculties, so that the Residents could quit or emigrate with a clear conscience?