"Walk a mile in their shoes" is a familiar saying urging us to be very careful before we criticize others. It's certainly a good life principle. More importantly it's a fundamental Biblical principle. At Mt. Sinai one of the basic laws was not to mistreat or oppress strangers because Israel had walked more than a mile in those shoes (Exodus 22:21).

God also approached it from the positive side. Beyond understanding others before criticizing them we should walk the extra mile and love the stranger (Deuteronomy 10:19), which is a variation of what Jesus called the second greatest commandment (Mark 12:31). This is a very important OT theme that’s frequently repeated. "Do not oppress a foreigner (Exodus 23:9), "Do not defraud or rob your neighbor" (Leviticus 19:13), "Love them (strangers) as yourselves" (Leviticus 19:34), just to name a few.

In the many passages about properly treating others God gave several reasons, but they all tie back to God's own nature. In one passage warning against oppressing the stranger God included a ban on oppressing orphans and widows because He's their champion (Exodus 22:22-24). Leviticus 19:24 simply stated "I am the Lord your God" as sufficient reason for them to love the stranger.

We should recognize the principle having seen it powerfully demonstrated in the life of Jesus. The Son of God came to earth and “was made a little lower than the angels" to call us His "brethren" and be made "perfect through suffering" so He could deliver us from the bondage of sin (Hebrews 2:9-18). So when God tells us to love our neighbor, including the stranger, He knows it can be done because He has walked more than a mile in our shoes.