Editor's Note: Tune in Sunday at 10a.m. or 1p.m. ET for Fareed Zakaria GPS on CNN.

By Fareed Zakaria, CNN

This past week, the Supreme Court deliberated over a controversial Arizona immigration law. It comes amidst a climate of hostility. Just look at what candidates said during the Republican primaries:

"Mitt Romney will complete construction of a high-tech fence," the candidate announced on his campaign website. Michele Bachmann promised to "build a double-walled fence." And Herman Cain said: "We're going to have a fence; it's going to be 20 feet high; it's going to have barbed wire on the top."

The fence in question guards a third of America's 2,000 mile-long border with Mexico. Supporters of harsher laws argue that 3 out of every 5 illegal immigrants are from Mexico. But just as American hostility is reaching a crescendo, the problem might be disappearing.

I was struck by a Pew report I saw this week. It says a historic pattern of migration has been reversed. Comparing two recent five-year blocks, the report finds that not only has the number of Mexicans immigrating to the U.S. declined by 50 percent (from 3 million to about 1.4 million), the number of Mexicans going the other way back home has doubled. Seven hundred thousand Mexicans in the U.S. moved back between 1995 and 2000. But that number increased to 1.4 million between 2005 and 2010.

The decline in illegal immigrants is no surprise. Even President Obama has spent more on immigration enforcement than his predecessor. What is surprising however, is the drop in net legal migration.

This has several explanations. The U.S. economy is weaker. On the other hand, Mexico's economy is strengthening. Its GDP per capita is 15,000 dollars - about a third that of America's.

Some of Mexico's competitiveness is due to NAFTA - the North American Free Trade Agreement. Because it avoids U.S. tariffs, its exports work out to be cheaper than China's. Last year, Mexico did 400 billion dollars worth of business with the U.S. That's more than Argentina and Brazil combined.

But whatever the set of reasons behind the Pew findings, immigration is always determined by both pull-and-push - the need to leave a place is as crucial as the lure of a new destination.

So, are we losing our allure?

If that's the case, that's not good news. The U.S. has always benefitted from being demographically dynamic. A major advantage we have over Japan, Europe, and even China is that our population will continue to expand. And it's been expanding with young people who are hard-working and full of drive and pay lots of taxes.

Look at the data: The median age in the U.S. was about 37 years in 2010. China's was lower at 34 years. But come 2050, that dynamic will be reversed, thanks to decades of Beijing's one-child policy and American immigration. The median age here will be 40 but in China it will hit nearly 49 years.

An aging country creates a deficit of workers and a surplus of retirees who spend. Our demographic advantage holds true against a number of countries. We're projected to be better off demographically than France, the UK, Korea, Spain, and, of course, Japan.

This demographic advantage is entirely due to immigration. The United States has a fertility rate not so different from European countries, so our population gains (and these are gains in young people) come entirely from immigration.

The Pew Study shows we've clamped down on illegal immigration. But it also shows that Mexicans don't want to come here as much legally as they did before. So it is actually a mixed picture.

In trying to one-up each other on building bigger and higher fences, demonizing illegals, and hoping that they self-deport, we seem to have forgotten that it is the spirit of acceptance and hospitality that has made America so attractive to legal immigrants for centuries. Let's hope we can stay that way.

Tune in Sunday at 10a.m. or 1p.m. ET for Fareed Zakaria GPS on CNN.