Ah, it's a good question. Apple was founded in the U.S. obviously, but U.S. companies can and sometimes do move their headquarters to another country. Burger King did it in 2014, reincorporating in Canada for primarily tax reasons. You can look up "corporate inversions" to see some other examples.
But the advantages have be very large for this to be worth it. The U.S. is a great place to do business in many ways. And as you noted above, U.S. companies can still get a lot of "foreign" tax benefits by shifting assets around between foreign subsidiaries (Apple's Irish trick for instance).
There are also emotional complications. A company like Apple is not just headquartered in the U.S., it is tightly coupled with the U.S. cultural identity. Moving out of the U.S. would break some of those ties, with resulting harsh consequences for Apple in politics, culture, retail sales, maybe even employees. You can look up what happened after Burger King moved... people were pissed.
So the short answer is, they started in the U.S. and staying here has a lot of benefits, while moving would come with high costs and somewhat unpredictable risks.
> According to a report by a Congressional panel, Apple has avoided billions in taxes through the use of international subsidiaries.
> Apple has subsidiaries in Ireland where the company has negotiated a special tax rate of 2 percent. These units contract with manufacturers to assemble Apple products, sell the products to other subsidiaries for distribution, and return the profits up the chain of companies in the form of dividends. But some of these subsidiaries do not have a stated tax residence and pay no taxes at all.
This is from 2013 so I'm sure it's out of date-ish.
> These 3 subsidiaries are incorporated in Ireland, but have no country of tax residence
Looks like what I'm looking for is "country of incorporation and tax residence"
Seems like companies can choose to "file/create" their corporation in any country, then have miniature "subsidiaries" (is this the right word) in various other little countries.
A great example of this is Singapore. I’ve worked with a few companies in Asia and it’s amazing what: a) rule of law, b) stable political environment, c) free capital flows can do in terms of attracting capital.
Singapore is pretty much the only option in SE Asia and the money keeps flowing in.