How can we walk in another man’s shoes if they don’t fit us? The shoes may be too small, and if we try to walk in them we may experience pain. We may develop blisters on our feet. The shoes may be too big and if we try to walk in them our feets will get cold.
However, if we do walk in another man’s shoes, through the pain we experience, we may begin to understand a little bit of the pain they are experiencing in their life and we won’t be so quick to condemn them.
Joseph Smith taught that "whatever principle of intelligence we attain in this life, it will rise with us in the resurrection" (D&C 130:18) meaning the things we learn now will stay with us, and benefit us, even after our mortal lives end
To walk in someones shoes is a way to learn.