The dramatic turning point in the career of Will McAvoy, the once inoffensive network anchor in the new hit drama The Newsroom, comes when he's asked to explain why America is the best country in the world.

McAvoy tries to dodge the question. But when pushed he sheds his milquetoast persona to deliver a tirade.

"There is absolutely no evidence to support the statement that we're the greatest country in the world," he yells at a stunned audience. "We're seventh in literacy, 27th in math, 22nd in science, 49th in life expectancy, 178th in infant mortality [and] third in median household income … When you ask what makes us the greatest country in the world, I don't know what the fuck you're talking about – Yosemite?"

In melancholic tones McAvoy then opines: "We sure used to be," before going on to mourn the loss of the nation's moral purpose, innovative prowess and consensual possibilities.

The reverence for a lost, idyllic American past merely mixes mythology with amnesia. America has had many great achievements in its short lifetime. But while it may be returning to a gilded age it cannot claim a golden one.

"The essential characteristic of a nation is that all its individuals must have many things in common," wrote the 19th-century French philosopher Ernest Renan. "And must have forgotten many things as well." In just the postwar period, you'd have to forget McCarthy, segregation, Nixon, several assassinations, Vietnam and Iraq – to name but a few.

Nonetheless, the notion that America is in decline has gained a firm foothold in the national psyche over the last decade or so. A plurality (45%) believes the country's best days are in the past; almost as many (42%) think China will overtake the US as a world power. Bookshelves and newsstands are filled with explanations. In 2001 60% said economic globalisation was a positive development; two years later it was 42%; last year it was down to 36%.

This angst is found on both sides of the aisle. In 2004, Democratic presidential candidate John Kerry wrote the preface to a collection of Langston Hughes poems entitled: "Let America be America Again". Republican candidate Mitt Romney insists he'll return the nation to a day when "each of us could walk a little taller and stand a little straighter".

But while liberals are more likely to see the roots of this crisis as domestic – growing economic inequalities, religious zealotry, corporatisation of media and politics – conservatives are increasingly keen to perceive the primary threat as external: immigrants, Islam, foreigners and foreign trade.

The most marked slump in support for economic globalisation over the last decade has been among Republicans, as has the sharpest increase in anti-immigrant sentiment and fear of the threat of "radical Islam".

It is in this light that Romney's gaffes in London, the constant questioning of Obama's American identity and the attacks on Romney's record as a venture capitalist must be understood.

For among a core group of Republicans "foreign" has become an epithet – a slur wilfully blurring the distinction between non-American, un-American, liberal, non-Christian and non-white.

Paradoxically, those most likely to insist the US is the leader of the free world are simultaneously those most likely to both fear and disparage the very world they insist on leading – whether it's free or not. To these people America's best days were when Americans did not care what the rest of the world thought of them and the rest of the world loved them for it.

This trend is most obvious in a popular line of attack on Obama that implicitly – and increasingly explicitly – challenges his claim to be American.

Last week one of Romney's top surrogates, John Sununu, said he wished "this president would learn how to be an American". Romney himself claimed the president espoused a philosophy that was "in some respects foreign to the American experience".

This is of course a proxy for race made popular by the birthers, who, despite all the evidence, insist Obama was born in Kenya. In a world where direct racial attacks are out of bounds, "foreign" becomes a useful metaphor. This man, it says, is essentially not like us or even from us.

Branding him Muslim, as though this too were in itself an insult, has the same function. A recent poll revealed the proportion of Republicans who believe Obama is Muslim has doubled since 2008 and now stands at almost a third. The trouble with these dog whistles is now that everyone can hear them they are scarcely worthy of the name.

Romney had barely landed in London before an adviser explained the reason he appreciates the "special relationship" more than Obama is because Romney is "part of an Anglo-Saxon heritage".

But race is not all these attacks are about. For the continent they're most likely to tar Obama with is not Africa but Europe – ostensibly a region of economically failed states pampered by overly generous welfare that also happen to be allies. "This president takes his inspiration from the capitals of Europe," said Romney. "We look to the cities and small towns of America."

It's with this mindset that Romney undertook his disastrous trip to Britain, described in his book as a small island that "with few exceptions doesn't make things that people in the rest of the world want to buy". It's for this reason that accusations of outsourcing at Bain Capital, where he was once CEO, and ads about his offshore bank accounts have made him vulnerable.

For the party most likely to champion patriotism and leverage parochialism is also the party most likely to be bankrolled by multinationals and champion free trade. A significant portion of the Republican base – white working-class men – have seen their livelihoods threatened by the very neoliberal globalisation that their party seeks to extend. Profit has no intrinsic interest in patriotism, and capital, increasingly, is unfettered by the nation state. The capitalism they vote for and the capitalism they actually experience couldn't be more different.

But in the absence of any real opposition to that trend – Democrats support it too – many Republicans reach for the comfort blankets of hyper patriotism and xenophobia and the more accessible targets of immigrants, foreigners and Muslims.

Open borders for capital and closed minds for culture; classically liberal economics and classically illiberal politics.

Twitter: @garyyounge