I think at any given time a company the size of Apple has a very good idea of the exact costs and benefits of every potential decision facing them. Enough so that they have probably known for a very long time exactly what they'd need to see to make an investment like this in the US.
I also think most business people have really suffered from the rhetoric and class warfare we've seen over the last decade. Enough so that when they see a positive cultural change and a tax bill and regulatory atmosphere that makes it easier to do business they understand the importance of acting quickly and making sure people know that these changes do mean something.