‘The virus does not discriminate,” suggested Michael Gove after both Boris Johnson and the health secretary, Matt Hancock, were struck down by Covid-19. But societies do. And in so doing, they ensure that the devastation wreaked by the virus is not equally shared.

We can see this in the way that the low paid both disproportionately have to continue to work and are more likely to be laid off; in the sacking of an Amazon worker for leading a protest against unsafe conditions; in the rich having access to coronavirus tests denied to even most NHS workers.

But to see most clearly how societies allow the virus to discriminate, look not at London or Rome or New York but at Delhi and Johannesburg and Lagos. Here, “social distancing” means something very different than it does to Europeans or Americans. It is less about the physical space between people than the social space between the rich and poor that means only the privileged can maintain any kind of social isolation.

In the Johannesburg township of Alexandra, somewhere between 180,000 and 750,000 people live in an estimated 20,000 shacks. Through it runs South Africa’s most polluted river, the Jukskei, whose water has tested positive for cholera and has run black from sewage. Makoko is often called Lagos’s “floating slum” because a third of the shacks are built on stilts over a fetid lagoon. No one is sure how many people live there, but it could be up to 300,000. Dharavi, in Mumbai, is the word’s largest slum. Like Makoko and Alexandra, it nestles next to fabulously rich areas, but the million people estimated to live there are squashed into less than a square mile of land that was once a rubbish tip.

In such neighbourhoods, what can social distancing mean? Extended families often live in one- or two-room shacks. The houses may be scrubbed and well kept but many don’t have lavatories, electricity or running water. Communal latrines and water points are often shared by thousands. Diseases from diarrhoea to typhoid stalked such neighbourhoods well before coronavirus.

People in their shanties at Dharavi during the coronavirus lockdown in Mumbai. Photograph: Rajanish Kakade/AP

South Africa, Nigeria and India have all imposed lockdowns. Alexandra and Dharavi have both reported their first cases of coronavirus. But in these neighbourhoods, the idea of protecting oneself from coronavirus must seem as miraculous as clean water.

Last week, tens of thousands of Indian workers, suddenly deprived of the possibility of pay, and with most public transport having been shut down, decided to walk back to their home villages, often hundreds of miles away, in the greatest mass exodus since partition. Four out of five Indians work in the informal sector. Almost 140 million, more than a quarter of India’s working population, are migrants from elsewhere in the country. Yet their needs had barely figured in the thinking of policymakers, who seemed shocked by the actions of the workers.

India’s great exodus shows that “migration” is not, as we imagine in the west, merely external migration, but internal migration, too. Internal migrants, whether in India, Nigeria or South Africa, are often treated as poorly as external ones and often for the same reason – they are not seen as “one of us” and so denied basic rights and dignities. In one particularly shocking incident, hundreds of migrants returning to the town of Bareilly, in the northern Indian state of Uttar Pradesh, were sprayed by officials with chemicals usually used to sanitise buses. They might as well have been vermin, not just metaphorically but physically, too.

All this should make us think harder about what we mean by “community”. In Britain, the pandemic has led to a flowering of social-mindedness and community solidarity. Where I live in south London, a mutual aid group has sprung up to help self-isolating older people. The food bank has gained a new throng of volunteers. Such welcome developments have been replicated in hundreds of places around the country.

South African National Defence Force soldiers enforce lockdown in Johannesburg’s Alexandra township on 28 March 2020. Photograph: Luca Sola/AFP via Getty Images

But the idea of a community is neither as straightforward nor as straightforwardly good as we might imagine. When Donald Trump reportedly offers billions of dollars to a German company to create a vaccine to be used exclusively for Americans, when Germany blocks the export of medical equipment to Italy, when Britain, unlike Portugal, refuses to extend to asylum seekers the right to access benefits and healthcare during the coronavirus crisis, each does so in the name of protecting a particular community or nation.

The rhetoric of community and nation can become a means not just to discount those deemed not to belong but also to obscure divisions within. In India, Narendra Modi’s BJP government constantly plays to nationalist themes, eulogising Mother India, or Bhārat Mata. But it’s a nationalism that excludes many groups, from Muslims to the poor. In Dharavi and Alexandra and Makoko, and many similar places, it will not simply be coronavirus but also the willingness of the rich, both in poor countries and in wealthier nations, to ignore gross inequalities that will kill.

In Britain in recent weeks, there has been a welcome, belated recognition of the importance of low-paid workers. Yet in the decade before that, their needs were sacrificed to the demands of austerity, under the mantra of “we’re all in it together”. We need to beware of the same happening after the pandemic, too, of the rhetoric of community and nation being deployed to protect the interests of privileged groups. We need to beware, too, that in a world that many insist will be more nationalist, and less global, we don’t simply ignore what exists in places such as Alexandra and Makoko and Dharavi.

“We’re all at risk from the virus,” observed Gove. That’s true. It is also true that societies, both nationally and globally, are structured in ways that ensure that some face far more risk than others – and not just from coronavirus.

• Kenan Malik is an Observer columnist