Apple did not place themselves about the law, they went to a properly constituted court and asked the judge to rule on whether what the FBI was asking was lawful.
During those proceedings, they also explained how complying with the FBI's request would lead to a highly damaging corruption of the privacy of their users data.
They asked the judge to make a judgement which was that Apple were right in saying that the FBI had over-reached in their warrant.
The case was headed to appeals when the FBI withdrew after finding another way to get the information they needed. Notably they did so without Apple having to compromise security or user data privacy.
During those proceedings, they also explained how complying with the FBI's request would lead to a highly damaging corruption of the privacy of their users data.
They asked the judge to make a judgement which was that Apple were right in saying that the FBI had over-reached in their warrant.
The case was headed to appeals when the FBI withdrew after finding another way to get the information they needed. Notably they did so without Apple having to compromise security or user data privacy.