I'm going to be friends with someone out of pity
Who are you planning to be friends with out of pity?
Some guy, he has no friends right now.
You can befriend someone because they are lonely, I think that is admirable. It could mean a lot to him if no one else is interacting with him.
I'm going to befriend him because I pity him.
It is good to be friendly with lonely people but if you tell him you pity him you might offend him. Can you imagine how that would feel being told someone likes you because they feel sorry?