This is a real problem that the U.S. computer industry has. There are a LOT of really smart, well-educated people all over the planet and only so many immigration slots into the US each year. There are tons of stories of U.S. companies hiring foreigners they need for a short time, and then watching as they're forced to go home where they, of course, start a competing company. So they now have a competitor instead of an employee, and there's nothing they can do about it.
The US governments knows this is a problem,
immigration services has been working with silicon valley entrepreneurs for the last year to figure out ways to help avoid these problems. But as civil servants, the best they can do is make minor adjustments, only Congress can make big changes to immigration law.
Given all this, what Apple is doing makes perfect sense. This really isn't a money-saving thing like the factories are. Rather, it's a way to tap into talent that they have no way of bringing to California.