Clearly workforce considerations on both ends. Localities and countries want their workforces to be involved in cutting edge, innovative and critical technologies and multinational corporate giants want a workforce with skills equal to their costs.
You can get high-skilled workers at high cost (Germany, US, Japan, Korea) and they are profitable.
You can get low skilled workers at low cost and they are profitable.
Sometimes an area just has every skilled person working already and it creates a need to expand somewhere else. I would not be surprised if this is a factor in Taiwan like it is in some parts of the US.
The idea that local production of silicon chips would be environmentally advantageous because of reduced shipping is ridiculous. It makes sense for firewood or watermelons but the only thing more easily transportable than an IC is software.