They were being asked to effectively crack an iPhone to which they had no access at all without the keys. What they refused to do was reverse engineer software to break it open.
Wrong I'm afraid, and it is really important that we don't think of it that way. I'll explain later.
Apple are Apple, the creators of iOS. They do have the only keys that matter, the code signing keys. Possession of these allows them to write any software that any iPhone will unquestioningly install and run, no matter what it does. As it happens the court order obtained by the FBI asked them to write some software that was pretty mild in comparison to what Apple could actually do if they chose to. For example Apple can, if they wanted to, remote install a backdoor on every iPhone on the planet (iCloud is effectively that anyway). All the FBI asked for was unlimited PIN retries on one specific iPhone, a change requiring the modification of a single statement in the source code.
Also none of this is reverse engineering. For Apple it's forward engineering from the source code. For everyone else it's reverse engineering from handsets. Forward engineering is much easier.
So Apple were unable to claim that it was technically difficult or technically expensive to comply with the order, nor could they claim that it would affect every iPhone. The FBI were quite subtle in what they asked for, and had the court order been dragged through the whole legal system it was not guaranteed that Apple would ultimately win.
Apple chose to argue in public (loudly and at some length) that it would be commercially difficult. This was far less convincing than "technically impossible", especially as the degree of commercial difficulty was proportional to how loudly Apple complained about it.
As it happens the FBI found other means and the issue of the court order remains unresolved. Apple are left with the knowledge that there is an undisclosed flaw in an old version of iOS. We are left with an infuriated law enforcement system and a bunch of enraged politicians who may now pass a law imposing a backdoor. If that happens we may find ourselves wishing Apple had gone along with the FBI's original request.
That is why it's important that we don't plug the line that Ad Hoc assistance is somehow hard, difficult or damaging. By doing so we're more likely to end up with a universal backdoor. Which from a technology point of view is no better for law enforcement than something ad hoc, but is far more damaging to government-society relationships. Far better to have ad hoc law enforcement assistance provided by Apple on production of a reasonable warrant, with Apple effectively acting as guarantor that Uncle Sam is not taking the piss.
Thus Apple's strategy in this is now very risky. Though in their defence we don't know for sure if the FBI's request had been made in private first and rebuffed by Apple, or whether the FBI stupidly went straight to court thus making the issue public from the very beginning without asking Apple in private first. Either way it is now down to the politicians to make laws on the matter as they see fit on behalf of all Americans and one of those may be Donald Trump.
Also, unless Cook actually engages with them he won't be able to complain about whatever law they choose to pass. Of course we're not party to whatever private conversations are going on, but if he ignores people like McCain then he has no influence on what gets proposed and voted on.