The summary above is highly misleading, possibly because of the bad headline the NYT editor put on the story. The judge didn't rule on the merits at all. All he did is issue a preliminary injunctiion, which forces the drug company to maintain the status quo for the duration of the trial. The judge didn't "block an attempt by the drug company" he just deferred the attempt until the case is over. If New York wins its case, the judge will actually block the attempt by entering a permanent injunction.
In other words: this ruling only reflects a judgement that, until we know who wins, it's better to force the company to keep the drug on the market, which is obvious to everyone. It doesn't reflect a judgement on whether the drug company may legally withdraw the drug.