SAN FRANCISCO — The workers of Silicon Valley make unlikely revolutionaries. As a group, they are relatively wealthy, well educated and well connected.

While most here supported Hillary Clinton, tech workers are not the most obvious targets of President Trump’s policy ideas. Many who populate the world’s richest tech companies will be just fine if the Affordable Care Act is repealed. Most will not be personally inconvenienced by the proposed Mexican border wall.

Under Mr. Trump, tech workers could enjoy a windfall. They may get tax credits for child care costs, their companies may be allowed to repatriate foreign profits, and their coming income tax cuts might fund a luxury vacation or two.

This is all by way of saying: The protests that swept through Silicon Valley and Seattle in the last two weeks were not motivated by short-term financial gain. If you want to understand why tech employees went to the mat against Mr. Trump’s executive order barring immigrants from seven Muslim-majority countries, you need to first understand the crucial role that America’s relatively open immigration policies play in the tech business.

And you need to understand why people in tech see something cataclysmic in Mr. Trump’s executive order, and in the other immigration crackdowns waiting in the wings: the end of America’s standing as a beacon for the world’s best inventors.

“Silicon Valley is unlikely, as a phenomenon — it is not the default state of the world,” said John Collison, an immigrant from Ireland who is a co-founder of Stripe, a six-year-old payments start-up based in San Francisco.

One important reason Silicon Valley can exist at all, he said, is that it is welcoming to people from far outside its borders. “I go all across the world, and every other place is asking, ‘How do we replicate Silicon Valley where we are — in London, in Paris, in Singapore, in Australia?’”

The reason those places have so far failed to create their own indomitable tech hubs is that everyone there wants to come here.

“The U.S. is sucking up all the talent from all across the world,” Mr. Collison said. “Look at all the leading technology companies globally, and look at how overrepresented the United States is. That’s not a normal state of affairs. That’s because we have managed to create this engine where the best and the brightest from around the world are coming to Silicon Valley.”

But, Mr. Collison added, “I think that’s kind of fragile.” Under Mr. Trump, the immigrant-friendly dynamic could change — and it could bring about the ruin of American tech.

To outsiders, this may sound alarmist, and perhaps more than a little self-righteous. Silicon Valley gets rightly rapped for talking a big game on its supposed meritocratic openness while failing on basic measures of diversity and inclusion. Women and non-Asian minorities make up a tiny fraction of the industry’s employees, and an even smaller portion of its executives and venture capitalists. In short, the tech industry is in thrall to white dudes as much as just about any other business.

And yet even a casual trip through most histories of the technology industry reveals an outsize role played by immigrants.

Last year, researchers at the National Foundation for American Policy, a nonpartisan think tank, studied the 87 privately held American start-ups that were then valued at $1 billion or more. They discovered something amazing: More than half of them were founded by one or more people from outside the United States. And 71 percent of them employed immigrants in crucial executive roles.

Collectively, these companies, which include householdish names like Uber, Tesla and Palantir, had created thousands of jobs and added billions of dollars to the American economy. Their founders came from all over the world — India, Britain, Canada, Israel and China, among lots and lots of other points around the globe.

In 2011, an immigration reform group, the Partnership for a New American Economy, found that more than 40 percent of companies in the Fortune 500 were founded by immigrants or the children of immigrants. For the newest members of the Fortune 500, many of them technology companies, the rate of immigrant founders was even higher, the organization said.

That should come as no surprise if you are familiar with the origins of the most iconic companies of the last few decades. One of Google’s founders is an immigrant from Russia, and its current chief executive is an immigrant from India. Microsoft’s chief executive is also from India. EBay and Yahoo were started by immigrants. Facebook’s largest subsidiaries, Instagram and WhatsApp, were both co-founded by immigrants. Apple was started by a child of immigrants.

There are many theories for why immigrants find so much success in tech. Many American-born tech workers point out that there is no shortage of American-born employees to fill the roles at many tech companies. Researchers have found that more than enough students graduate from American colleges to fill available tech jobs. Critics of the industry’s friendliness toward immigrants say it comes down to money — that technology companies take advantage of visa programs, like the H-1B system, to get foreign workers at lower prices than they would pay American-born ones.

But if that criticism rings true in some parts of the tech industry, it misses the picture among Silicon Valley’s top companies. One common misperception of Silicon Valley is that it operates like a factory; in that view, tech companies can hire just about anyone from anywhere in the world to fill a particular role.

But today’s most ambitious tech companies are not like factories. They’re more like athletic teams. They’re looking for the LeBrons and Bradys — the best people in the world to come up with some brand-new, never-before-seen widget, to completely reimagine what widgets should do in the first place.

“It’s not about adding tens or hundreds of thousands of people into manufacturing plants,” said Aaron Levie, the co-founder and chief executive of the cloud-storage company Box. “It’s about the couple ideas that are going to be invented that are going to change everything.”

Why do tech honchos believe that immigrants are better at coming up with those inventions? It’s partly a numbers thing. As the tech venture capitalist Paul Graham has pointed out, the United States has only 5 percent of the world’s population; it stands to reason that most of the world’s best new ideas will be thought up by people who weren’t born here.

If you look at some of the most consequential ideas in tech, you find an unusual number that were developed by immigrants. For instance, Google’s entire advertising business — that is, the basis for the vast majority of its revenues and profits, the engine that allows it to hire thousands of people in the United States — was created by three immigrants: Salar Kamangar and Omid Kordestani, who came to the United States from Iran, and Eric Veach, from Canada.

But it’s not just a numbers thing. Another reason immigrants do so well in tech is that people from outside bring new perspectives that lead to new ideas.

Mike Krieger, an immigrant from Brazil who is a co-founder of Instagram, the photo-based social network app, said one reason it found instant, international success was that he purposely eliminated most text from the app. He knew from growing up in Brazil that English would hinder adoption in most parts of the world.

“Every step of the way while we were creating it,” he said, “we were thinking, can you create something with international appeal?”

Mr. Collison, of Stripe, said he could not imagine creating a company without immigrants. “In the early stages of a start-up you usually have a very specific set of things you need to do, and there’s a very short list of people who are able to do them,” he said.

In its early years, Stripe needed engineers and executives to build its system for moving money around the world; it needed to create a novel machine-learning system to detect fraud; and it had to convince regulators and other businesses that it was safe and legal to process payments through Stripe. The people it found for all these roles happened to be immigrants.

“The fact that we can do that in Silicon Valley — the fact that the talent is here or that we can bring the talent here, that’s what makes the whole thing work,” he said.