Companies definitely should disobey the law by refusing to comply with a valid search warrant in cases where someone is being prosecuted for having an abortion. Obeying the law in this case is clearly immoral!
This does not entail that obeying the law is always immoral, or even that breaking it is always moral. You can come to the conclusion that it is okay for companies to break some laws but not others in at least two perfectly reasonable ways: you can believe that breaking laws is not in itself a bad thing (but that actions that break some law may be bad for some other reason, such as harming people), or that it is a bad thing but in some cases the lesser of two evils.
However, in practice it may be difficult for a company to organize such disobedience, particularly since, for example, Facebook cannot avoid hiring employees from religious groups who are in favor of these laws, and also because the court order may not inform Facebook what the case is about. So, a more practical approach is to avoid being in the position of surveilling people's private communications in the first place, so that no employees at the company have access to the information the police seek. End-to-end encryption is a crucial structural protection against this kind of pervasive surveillance, because it prevents intermediaries from having the private information in the first place. Pseudonymity is another one: the teenager should never have given Facebook her legal name, but unfortunately Facebook has extensive policies in place to extort legal names from its users, making them vulnerable to such abuses.
Of course talking about encryption always brings out the knuckledraggers who link to XKCD 538 and talk about hitting people with $5 wrenches. Hopefully this example clarifies why encryption sometimes defeats a $5 wrench: neither Celeste Burgess, the Nebraska teenager, nor the Facebook employees were ever at risk of being beaten with a wrench in this case.
(originally https://news.ycombinator.com/item?id=32402302, edited a bit)