If a random mutation/variation makes an organism fitter and able to breed more prolifically, that trait will be passed on; if that trait allows individuals which have it to out-compete the others that do not, then eventually they will dominate and the others will die out. With this in mind, there are some significant advantages to living in groups, a few of which might be:
Safety in numbers
The ability to kill, deter or scare off predators that an individual would be killed by, and the ability to defend larger territories against members of the same species
- The ability to obtain better or more varied types of food, or larger quantities of food, than an solitary animal could obtain on its own. Consider the difference between a cheetah, which often struggles to kill animals of a similar size and weight, to a pride of lions or a lack of wolves, who are capable of taking down animals that could kill an individual
- The ability to share duties and live more efficiently than a solitary member of the species: shared parenting, or adopting orphaned young; keeping watch for danger in shifts, allowing more time to sleep and gather food in safety; working together to construct larger or more effective dwellings/shelters.
- The possibility of "looking out for one another", e.g. If a sick or wounded member of the group can survive and in turn reproduce due to the care of its fellow group members, when a solitary animal in the same situation would have died
- The option of specialisation within the group: either phenotypically, as in bees, where you have specialist workers, soldiers and breeders; or behaviourally, as in humans, where craftsmen and innovators have the freedom to develop skills and advance collective knowledge because other specialists are taking care of food and protection.
The only thing to consider is whether there is an overall benefit after considering the main disadvantage of living collectively, namely that resources have to be allocated/shared amongst the group. The amount of food distributed to each member should be equal to or greater than what a solitary animal could obtain and keep all for itself, for example.