In 2011, in what seemed like a laying to rest of the mad ghosts of Anglo-Irish history, the Queen was cheered to the rafters in Dublin.

But the building in which this celebration of amity took place had its own rather haunting presence. It was the spanking new Convention Centre, a glamorous, ultra-modern monument to the optimism of the Celtic Tiger years. By the time of the Queen’s visit, it looked out on a landscape of shattered dreams. From the top floor, you had a panoramic view of abandoned building sites on the other side of the Liffey, testaments to the folly that created a spectacular banking crisis, vicious austerity and deep disillusion with the political system that had brought such pain.

If you stand there now, what is most striking is not what you see but what you don’t see: those jagged gaps that less than a decade ago made Dublin’s docklands look like a mouthful of broken teeth. Nearly all the holes have been filled in by headquarters of multinational companies and the lawyers and bankers who serve them.

The Irish economy is overflowing again, this time on a wave of outside investment. In 2018 alone, foreign direct investment into Ireland rose by 52%. (It fell by 13% in the UK and these two figures are probably not unrelated either to each other or to Brexit.)

One can question how much of this is sustainable and about how much of it is just vast multinationals moving money around to take advantage of Ireland’s 12.5% corporation tax rate. But right now a lot of it is real and visible and not just in Dublin. Employment has risen for 29 consecutive quarters since 2013 and is now higher than it was before the crash. Ireland again looks like a big winner in the game of economic globalisation. Which prompts the obvious question: how come an angry electorate has just thrown out the Taoiseach, Leo Varadkar, and given the largest single share of a very fragmented popular vote to a party that was once a pariah, Sinn Féin? To get to grips with this seeming contradiction is not just to comprehend contemporary Ireland, it is to grasp something important about globalisation itself.

When we think about the rise of nationalism and populism from the US and Britain to Brazil and India, we usually talk about the people who are losing out: the rage of those “left behind” by the globalising forces. And if you were looking from the outside at what has just happened, you would quite reasonably assume that Ireland, which has seemed relatively immune, has just succumbed to the same virus. Sinn Féin, after all, is rooted in the extreme, violent nationalism of the IRA and one of its jubilant election winners even celebrated by shouting “Up the ’Ra”.

Nobody expected it – including Sinn Féin itself, which failed to stand enough candidates to take advantage of its vote

But this perception is wrong, for two big reasons. First, nationalism had relatively little to do with the Sinn Féin surge. Second, and more intriguingly, the anti-establishment rage that drove voters towards Sinn Féin, the Greens, the Social Democrats and almost anyone except the parties that have run the state for almost a century, is not a reaction against the failure of globalisation.

It is a reaction against the success of globalisation. Ireland has not been left behind – it is, on the contrary, at the forefront of this vast process. But what the election tells us is that, even for the winners, the existing model of “free market” globalisation is deeply flawed: it cannot produce, even in a rich society, the public goods that citizens expect.

That the Sinn Féin surge is not an embrace of militant nationalism is obvious from the very fact that it was indeed a surge. Nobody expected it, including Sinn Féin itself, which failed to stand enough candidates to take advantage of its vote. People were right not to expect it. Sinn Féin has had a string of woeful outings: in the Irish presidential election in 2018; in the local and European parliament elections last May; and in the Westminster elections in Northern Ireland in December.

Its core vote in the Republic is the 9.5% it got last May. Most of the 15 percentage points it has added in eight months come from people who never previously voted for the party. They did not do so because they are not interested in Sinn Féin’s nationalist brand. They did so now because they were very interested indeed in its policies on housing and healthcare. A united Ireland was nowhere in the list of reasons given in an exit poll by voters for their choice – Brexit, which might be taken as a surrogate for the issue in an Irish context – was cited by 0% of Sinn Féin voters.

But those issues that did matter – housing and health – tell us a great deal about what it feels like to live in a society that is winning the globalisation game. People have jobs – often well-paid ones. But they can’t afford to pay the rent. Over the period since the Irish economy started to recover in 2013, real disposable incomes in Dublin have risen by 13%. Which sounds great – except that house prices have risen by 62%, pushing rents up with them. And while the young worry about having a place to live, for older people the biggest election issue was Ireland’s increasingly privatised health system that treats people according not to their needs, but to their wealth.

Voters are now asking their next government to conduct a fascinating experiment: can Ireland retain the global investment that makes its economy look so successful, while providing the public goods without which its society is not sustainable?

• Fintan O’Toole is a columnist with the Irish Times