I guess I've never thought much on it because in a lot of ways I see the greeting as a formality, and that often includes hugs, handshakes, etc. I know the relation of where I stand with the friend based on what we do, what we talk about, and how comfortable we are with each other. I do suppose that physical contact is just another way of being comfortable though.
Of course the logic falls apart when you consider that I hug more of my female friends (although even then it's when they're close). I remember hanging out with a couple of gay acquaintances a couple years back and they all hugged for greetings, which in retrospect did throw me off a little (although I did hug back, when it comes to family I'm used to that). So my rational explanation above is probably not the main reason for it.