People tend to be drawn to others who have similar interests. They can also be attracted to people with similar beliefs, morals, and standards for living. This can be both good and bad.
On the good side, morale is high in a group of people who share interests and beliefs. Production can be outstanding for instance in an work setting or in fundraising. Social activities are obviously more enjoyable if people share common interests.
On the bad side, it can be taken to extremes... witness the Klu Klux Klan.
Some folks use this phrase with a negative slant to it, suggesting that people are like lemmings... that they just flock together, following a pack so to speak, without any thought to being individuals.
"Birds of a feather flock together." It means that people who are similar are probably going to spend more time together because they have something in common. It contradicts the saying "opposites attract", though.