Updated Jun 8
Sometimes, it is based on feeling offended that somebody is different to themselves, including interpreting that as a personal judgement or attack upon themselves.
However, this can arise even if you have the majority ethnicity, the majority language, and an appearance that looks average (i.e. you don’t speak, dress, worship, or act “foreign”). In a way, that might seem even more jolting to them, such as with the sudden, unexpected foreign accent that comes out of your mouth. Like you were deceiving them with the “normal” appearance. It also defuses their resentment-excuse of, “Those obnoxious, weird-looking foreigners who refuse to assimilate into our society”.
If you resemble the majority, then some people who know that you are an immigrant may casually assume that you share their negativity towards different-looking immigrants, including racism.
Upon meeting, some may first jump to the conclusion that you are a clueless tourist or “semester-abroad” student, and then resent being told that they were wrong about something.
It can also be a sense of competition and tall-poppy syndrome.
They may feel trapped, handcuffed, and powerless in life in general, and geography is a sort of symbol or shorthand for that.
There may be a sense that, the immigrant has asserted more independence and control over her life. And has a more interesting life, with wider experiences and knowledge. Which may also be viewed as boosting social status (i.e. worry that other people may view the immigrant as a more interesting person, and the non-immigrant as a boring loser). While failing to grasp that the immigrant actually has lower social status.
When they interrogate you with the tedious, “Where are you from and why are you here?” routine, they may feel agitated at admitting that you possess information which they don’t possess. They don’t like the risk that you might tell them that it is none of their business.
They may feel indignant that, you got off the couch, made a decision, and proceeded to action, without consulting them first. Which implies that maybe the world doesn’t really revolve around them, and maybe they don’t really have authority over everybody else.
They may get indignant and claim unfairness (“I never get to go anywhere that Iwant!”). Or they may claim that, remaining stuck in one place makes them superior, like they are living life the “right”, mature, responsible way.
The independence issue is common among women, with the pervasive idea that, geographic location is based on emotional and/or financial dependence on someone else. This is one reason for the pattern of women getting much more agitated/resentful (and more interrogatory) than men (who often don’t care).
A woman who feels that her location is dictated by her emotional dependence on her mother will resent a woman cuts the cord and relocates.
A woman who moved to a new city (not necessarily a new country – just a new city) due to her breadwinning husband’s job will resent a single woman who moved voluntarily and alone.
Some people may look for rationalisations, like you are sneaking around, or gaming the system. Or that you are running away from obligations, such as child support. Or they think that you pay taxes to your original country, but not the one to which you immigrated. Some actively hope that you are an illegal immigrant who overstayed a tourist visa, and that you are subject to deportation. They may like the idea of your life-control being forcibly taken away from you (possibly by them reporting you to immigration authorities).
Excuses for treating you with contempt may include believing that you are on some kind of very long vacation, full of leisure and adventure, and that you somehow don’t have to work.
Other rationalisations include stereotypes about certain nationalities, even if you don’t really match the stereotype. Or they may act like the government of your birth-country reflects on you personally (e.g. you may be assumed to support military invasions and obnoxious elected officials). Or that, high-profile crimes in your birth-country reflect on you personally (e.g. American gun violence).
Some natives feel very defensive, and may treat you like you are being offensive if you assert your right to voice legitimate criticism of the country to which you immigrated. Including if you talk about how immigrants are treated.
Some people may have a kind of national self-esteem issues, which may come up if you are originally from a country which they view as more glamorous. This can also go down to the level of being from a prominent and supposedly glamorous city. Including if their perception comes solely from television, cinema, etc.
Some may act friendly when they think that they can somehow use or exploit you (including to somehow make themselves seem cool by association). But, if you reject them, they may lash out, with “Go back to your own country” used as a way of claiming that it is really them rejecting you (and thus them being in the power position).
Some will get upset if you even just relocated from one city to another, inside the country. They may get even more upset if you state that, you reserve the right and ability to pack up and relocate again, by your own choice.
I have encountered people who believed that everyone who attempts to relocate (whether to a new country, or even just to a new city) almost immediately panics, gives up, turns around, and goes back where they came from. Or that, nobody ever attempts to relocate, and that it is consciously planned as a short-term visit, with a specific date to “go back home”. They think that, a person’s geographic location (the specific town or city) is externally dictated, set in stone when they are a child, and that they “have to” stay stuck right there for their whole life.
They might not have even visited anywhere outside the local area. They may imagine that, it would be frightening and disorienting to go anywhere new and unfamiliar, especially alone. They may feel that you are obligated to validate that idea, and feel personally offended if you refuse to do so.
Some people lack the skill (i.e. map-reading) and psychological aptitude to even navigate themselves to unfamiliar locations inside the local area. And they may be highly disturbed if you imply that you are capable of it, in terms of both skill and your psychological comfort.
TLDR: Some of the xenophobes or immigrant-phobes couldn’t even get their own act together to move to a different suburb.