The word for realizing that other people are people too, with stories and depth
Solution 1:
I believe 'sonder' is the word you're looking for; however, the word's true definition is disputable.
Here is the definition from The Dictionary of Obscure Sorrows (which is actually a blog, not a dictionary):
n. the realization that each random passerby is living a life as vivid and complex as your own—populated with their own ambitions, friends, routines, worries and inherited craziness—an epic story that continues invisibly around you like an anthill sprawling deep underground, with elaborate passageways to thousands of other lives that you’ll never know existed, in which you might appear only once, as an extra sipping coffee in the background, as a blur of traffic passing on the highway, as a lighted window at dusk.
Solution 2:
'sympathy' fits this idea well.