If you want to understand how patriotism works in the United States, a good place to start is a swim meet in southern California, near the University of California, Irvine campus. It’s hot, and kids are lined up by the pool in swim suits, ready to race.

But before the meet can begin, the crowd hushes, then belts out the contorted notes of The Star Spangled Banner.

David S. Meyer, a sociologist who studies political movements and dissent at UC Irvine, is at the meet cheering on his kids. In many other countries, he notes, the local national anthem rarely gets sung before professional sporting events, much less kids’ swim meets. The constant American habit of repeating patriotic declarations can befuddle foreign visitors, who “think that it’s totally bizarre,” Meyer tells Inverse.

Even within the U.S., not everyone knows how to react. “There are people who stand at attention and take their hats off, hand on heart and sing along,” he says. “People who stand up and look around. People who pay attention to the music. And some people who are kind of nervous.”

So what’s the point of all that time and effort praising American glory? Research suggests that in a diverse nation like America, patriotism can bind people together — and help identify outsiders.

In a study published in April in the journal Psychological Science, scientists had two groups of people learn and perform different rituals together. These rituals had no particular meaning — just a lot of shuffling around and arm-waving, mostly — but after each group took their turn performing their own ritual, experiments showed that subjects who had previously never met one another were much more likely to trust members of their own group and distrust members of the opposite group.

Reminders of group differences seem to be similarly powerful at the national level. A group of four studies conducted in Germany and Britain and published in the journal Social Psychology in 2001 found that reminders of allegiance differences between groups can cause spikes in bias. Ask Germans and Britons circa 2000 to compare their nation’s present to its past, and they were likely to express a lot of love of country, but no major increase in distaste for foreigners. But prime them with reminders of the difference between their countries and other countries, and bias against outsiders goes way up.

Meyer believes Americans tend to come back to patriotic rituals over and over because, as a country, we’re nervous that there’s little else binding us together. No single ethnic or cultural identity is uniquely American.

“Until very recently, if you took a European trip and you got off a train in Berlin, people looked very different and dressed very different than the people you’d see when you got out of a train station in Paris or Madrid,” Meyer said.

Absent the shortcuts of strong ethnic and cultural affiliation, Americans return again and again to patriotic symbols: songs, the Pledge of Allegiance, the flag.

Those symbols are heavy with psychological impact and national importance but light on content. The pledge alludes to some vague common ideals: liberty, justice, God, and the Republic. The anthem tells a shared, mythologized story of overcoming British might. And the flag is literal — 13 stripes for 13 original colonies, and 50 stars for 50 states. And since patriotism is so nebulous, it can be used to get across almost any message.

“When someone makes an argument, one way to refute it is to look at the proposal and go point-by-point through and refute it. Mostly that’s a losing strategy in politics,” Meyer said. “A more effective way to engage in political debates is to discredit the sponsor of the idea. So you say the person who’s sponsoring this idea is crazy, is un-American, is a traitor, is not authentic, is representing some foreign power, so they’re not really looking out for America.”

It turns out that the way you deploy the patriotic cudgel matters. A study published in the journal Political Psychology in 2007 found that introducing patriotic symbols into a political discussion can warp the terms in which people think about the issues. Talk to people about patriotism as an ideal of common purpose, working toward goals together, and they’re more likely to embrace expansive political ideas. Multiculturalism and social identities become more appealing, and more important. But prime people with the suggestion that there’s something essential about Americanness, and they’re likelier to reject outsiders or variance from a “common cultural standard.”

There’s nothing inherently right wing or left wing about patriotism or patriotic symbols, Meyer said. But flag-waving often seems to be associated with a right-wing politics in America.

A series of experiments published in the journal Political Psychology in 2008 showed that exposure to the American flag tends to make people more supportive of authoritarianism, more opposed to racial and gender equality, more antagonistic toward foreigners, and more supportive of the idea that America should dominate the world.

And researchers have long known that this effect redoubles in wartime. The political scientist John Mueller in 1970 described what he termed a “Rally ‘Round the Flag” effect, wherein nearly any new military event — a bombing campaign, an attack on the homeland, an invasion of a foreign country — prompts surges in nationalist patriotism and the popularity of the American president. It doesn’t matter why violence is happening. As long as American might is on display, people get pumped up.

In the decades since, Mueller’s ideas have seemed to have been verified repeatedly. Just a couple weeks after the 9/11 attacks, President George W. Bush charted the highest presidential approval rating in Gallup polling history: 90%. After the raid in which Navy SEALs killed Osama bin Laden, President Barack Obama grew more popular. President Donald Trump’s approval ratings climbed after an April bombing of an airbase in Syria.

But war-patriotism has a short shelf-life. “Over time you’ve got to offer more than that, and it’s hard to keep offering more than that,” Meyer says. Overusing a patriotic symbol can be problematic, and deploying it asks, Who are we? What holds us together? What do we have in common? Why are we together? Do I belong? Do they belong, whoever ‘they’ is?

A group of school kids reciting the Pledge of Allegiance in homeroom, or Californian swim parents half-heartedly singing the Star Spangled Banner before a swim meet might not feel any deep, stirring patriotic fervor. But everyone gathered is reminded who belongs — and who doesn’t.

Photos via Unsplash / Filip Bunkens, Unsplash / Aaron Burden, Rafi Letzter/Inverse