> There's no law against leaving a country
It may actually be illegal in US law for Apple to leave the UK market for ideological reasons. Public companies are beholden to shareholders and can be sued for not acting in their interest (fiduciary duty, Delaware General Corporation Law). (I loathe these laws, but that's a separate discussion entirely.)
So sure they _can_, but at a cost that strikes the option from the cards entirely.