It's human nature to desire bonding, relationships, and communication with others. When people become friends and remain friends, they do so because they enjoy each others' company, or they have common goals and interest that have brought them together.
We are hard-wired to like people because we fundamentally do not want to be alone. On the most basic, animal level, we will be failures - and will die - if we do not have friends or family to help protect us.
This is not 100% always true, of course, but I think it describes our urge towards friendship on a very basic level. However, this is only speaking of why we make friends, not why we stay friends.
Long-lasting friendships are not rare, but friendships that remain equally close over long periods of time without interruption are quite rare. I don't want to put too fine a point on this, but it seems to me that "friendships" can be loosely defined, at least loosely enough to allow for someone to deem a kindergarten buddy as a friend at the age of 40, despite speding 35 years apart and seeing one another once a year during the interim.
It starts by happenstance, but from there, it's all about caring about the other person. It is not necessary to really have that much in common. People become and stay friends all the time even if they have many things that are different. All it takes is that undefinable "chemistry."
I think a lot of it has to do very simply with happenstance. I moved away (not that far away, but far enough) from the place where I grew up, and have maintained few lasting friendships from my childhood. The same is true of other people who left. I know many people, however, who have stayed in the area, and had remained close friends with people we went to school with.
I agree that common interests, etc., are important, but I also think in our very mobile society, it can be hard to build lasting friendships. That's part of the appeal of social media, I think.
People tend to become friends for one of two reasons: true friendship or desire to gain something from the friendship. While the person who desires the friendship normally does not tell the other person that they are only friends with them because they can gain something from the friendship, friendships like this do not last.
The friendships which tend to last are those built on mutual respect and commonalities. These friendships are the ones where each person benefits (equally) from the relationship.
Well, they don't always. I have had many friends over my 56 years who have come and gone, but I still stay in contact with many old friends from elementary school, high school and college. I have always found that old friends are the best friends, and having just moved back to my home town, I'm having a great time reuniting with some I haven't seen for years.
We are social beings that enjoy the company of others. Without friends, we would naturally feel lonely and depressed. I think it is only natural for us to have friends, although they don't always stay, as people change with time.