As with many things, its complex. A couple reasons:
Propaganda on social media uses immigration as a wedge issue to divide people. For example, the Kremlin wants to get people angry about immigration AND angry about people trying to stop immigration. “They’re coming to eat your pets” and “anti-immigrant peoppe are all hateful racists”
The planet is overpopulated. We’re running out of land and resources, and that makes people worried and protective of their territory.
As with many things, its complex. A couple reasons:
Yup, immigrants were often effectively scabs. Brought in to suppress wages and unions. Harder to form a union when everyone speaks different languages