The crops are all in and the peaches are rott'ning,
The oranges piled in their creosote drums;
They're flying 'em back to the Mexican border
To pay all their money to wade back again
Goodbye to my Juan, goodbye, Rosalita,
Adios mis amigos, Jesus y Maria;
You won't have your names when you ride the big airplane,
All they will call you will be "deportees"
My father's own father, he waded that river,
They took all the money he made in his life;
My brothers and sisters come working the fruit trees,
And they rode the truck till they took down and died.
Some of us are illegal, and some are not wanted,
Our work contract's out and we have to move on;
Six hundred miles to that Mexican border,
They chase us like outlaws, like rustlers, like thieves.
(from) Plane Wreck at Los Gatos Woodie Guthrie
An illegal alien is a person who resides in a nation of which they are not a citizen without the permission of the host nation. Generally this is an extreme case of being a resident alien, with added disadvantages. Prior to the development of the modern concept of nationhood this status may not exist as we would currently understand it … with foreigners in many cases starting in the next city along and all being equally (un)welcome in this one … but can also feasibly appear in pretty much any era.
In most eras the illegal alien will have migrated for economic reasons but, lacking citizenship or official recognition, will tend to find themselves confined to bottom tier work, whatever their actual skills and participating de facto in the black or grey economies and frequently being exploited as a result. A suitably corrupt state may even favour the use of illegal labour as a cheaper alternative to natives, possibly even to the extent that the economy comes to rely on them - although resistance from local guilds and/or trade unions should be expected1. Also, with very limited legal protection they tend to be vulnerable to predation by criminals and may be in very grave danger if relations between their home country and their host deteriorate.
In fantasy or sci-fi this status can also be applied to entire species which may be officially prohibited from living in a given area but may sneak in anyway (for example, goblins may be officially proscribed, but may still inhabit a city's slums and sewers … and may even be informally tolerated because they handle jobs that natives won't do).