There is something touching about God’s command in Exodus 22:21, “You shall not wrong a stranger or oppress him, for you were strangers in the land of Egypt.” Indeed I think it is intended to call out the empathy of God’s people for others: “for YOU were strangers in the land of Egypt .”
This verse calls for us to be sympathetic to those in situations that we have previously found ourselves in. It might seem that it should be natural for us to do that, but because of our sin nature, it is not always so. Sometimes in “putting the past behind” us, we forget what it was like to be a stranger somewhere – or lost in sin, or hurting with grief, or in financial need, or sick, or overwhelmed with young children, or whatever. God calls us here to remember how WE once were (and in some cases, may be again!) and to have mercy on others who are now in that state. Just in case we see ourselves as “above that” now, God “tugs on our heartstrings” in this verse, calling us to sympathy, and not prejudice; to compassion instead of condemnation. At heart it is an Old Testament foreshadowing of The Golden Rule: “Do unto others as you would have others do unto you” — remembering all the while what it was like to be there yourself!