I put "ego, self image," which for me is sort of half of it. I think it ultimately comes down to empathy. If I do something that makes someone feel sad/angry/frustrated/embarrassed/disappointed, or fail to do something that could have stopped them from feeling that way, then I'm acutely aware of the unpleasant feeling they're experiencing. Then I feel like an ass for making them feel that way (or not helping them not feel that way). I don't want to be an ass, or feel like an ass, or have other people think of me as an ass. So, I do my best to be nice.
Granted, being friendly comes naturally to me for the most part. The difficult part is not letting myself justify being nasty to people who are being nasty to me. It's so easy to say, "This person's being such a jerk to me, therefore she is a bad person, so it's okay to be a jerk to her," but the sad part is that she's probably thinking the same thing. I try very hard not to get trapped in that kind of cycle because I always feel like an ass after I cool off, but it's not easy.