Exodus 22:21

21 “Do not mistreat or oppress a foreigner, for you were foreigners in Egypt.

Read Exodus 22:21 Using Other Translations

Thou shalt neither vex a stranger, nor oppress him: for ye were strangers in the land of Egypt.
"You shall not wrong a sojourner or oppress him, for you were sojourners in the land of Egypt.
“You must not mistreat or oppress foreigners in any way. Remember, you yourselves were once foreigners in the land of Egypt.

What does Exodus 22:21 mean?

John Gill's Exposition of the Bible
Exodus 22:21

Thou shall not vex a stranger
One that is not born in the same country, but comes into another country to sojourn, as Jarchi; not a native of the place, but of another kingdom or country; a stranger to the commonwealth of Israel, that is only in it for a time on trade and business, or through one providence or another; or else a proselyte is meant, not a proselyte of righteousness, who has embraced the true religion; but a proselyte of the gate, that takes upon him the commands of the sons of Noah; or, as Aben Ezra here expresses it, who takes upon him not to serve idols; such were allowed to dwell among the Israelites, and they were to carry it friendly and kindly to them, and "not vex" them, nor irritate them with words, as the Targum of Jonathan, and so Jarchi; by calling them names, Gentiles, uncircumcised persons, and the like; upbraiding them with their country, ignorance, and manner of life; they were not to say to a proselyte, as Ben Melech observes, remember thy former works; or, if the son of a proselyte, remember thy father's works:

nor oppress him;
by taking his goods, as the above Targum, and so Jarchi; by refusing to assist him with advice or otherwise, to trade with him, or to give him lodging, and furnish him with the necessaries of life:

for ye were strangers in the land of Egypt:
out of which they were but just come, and therefore such a reason must be very striking and moving upon them: the Targum of Jonathan prefaces it,

``and my people, the house of Israel, remember that ye were strangers''

this they could not have forgot in so short a time, and the remembrance of this should move their compassion to strangers hereafter, when they came to settle in their own land; and therefore, as they would that men should have done to them when in such circumstances, the same they should do to others; and besides, the remembrance of this would serve to abate their pride and vanity, and their overbearing disposition.
California - Do Not Sell My Personal Information  California - CCPA Notice