An alien was not a slave, nor a prisoner of war, nor was he one of the idolatrous Canaanite tribes, who were to be exterminated or driven out. Rather, he was from a non-Canaanite tribe or nation, who travelled with or settled among the Israelites. The Law stipulated a surprisingly generous treatment of these aliens:
"You are to have the same law for the alien and the native-born. I am the Lord your God" (Lev 24:22).
This command is repeated frequently: see InDepth.
Aliens were permitted to share even in the religious life of Israel, including Sabbath observance (Ex 20:10, Ex 23:12), sacrifices (Lev 17:8), and Passover (Ex 12:48, Num 9:14). Furthermore, they were to have equal standing in legal disputes, as well as share in ancient welfare programs (gleaning) (Lev 23:22, Lev 25:35, Deut 1:16, Deut 24:14-21). They were not to be discriminated against:
"The alien living with you must be treated as one of your native-born. Love him as yourself, for you were aliens in Egypt" (Lev 19:34).
There are several repetitions of this verse: Ex 22:21, Ex 23:9, Deut 10:19.
Critics of Joshua's scorched-earth policy toward the Canaanites unfairly ignore the numerous references to justice for aliens. Leviticus was far more advanced and compassionate than most other nations, ancient or modern. In it we see the roots of later Judaism's tolerance for "God-fearing Gentiles." But this attitude must not be considered tolerance in a permissive sense - the alien was bound to live by the laws of the Jews, not his homeland. (See Ex 12:19, Ex 20:10, Lev 16:29, Lev 17:8-16, Lev 18:26, Lev 20:2, Lev 22:18, Lev 24:16, Lev 24:22, Num 15:14-16, Num 15:29-30).
God's compassion for foreigners was based on the experience of Israel in Egypt. It is not just that the Israelites were aliens in Egypt for 400 years. In God's eyes, they were still aliens, and would be forever:
"The land must not be sold permanently, because the land is mine and you are but aliens and my tenants" (Lev 25:23).
This teaches us that Israel's "chosenness" was not permanent but conditional, because tenants can always be evicted. Jesus makes the same point in the Parable of the Talents:
"the kingdom of God will be taken away from you and given to a people who will produce its fruit" (Mat 21:43).
There is no notion here of a "master race," qualitatively elevated above the rest of mankind.
The theme of Israel as an alien in Canaan does not recur in the Old Testament, but is mentioned in the New Testament. Here, after listing various Old Testament heroes, it says of them:
"All these people were still living by faith when they died. They did not receive the things promised... And they admitted that they were aliens and strangers on earth" (Heb 11:13).
So even in the Promised Land, Israel did not own the inheritance. God did not want them to be land-focused. What they owned was the Covenant, the status of being God's own people on the earth, no matter where they lived -- so long as they honored the Covenant, God's Presence in their midst.