Basically it is the same as any other selective pressure. The population of organisms gains a reproductive advantage and increased survival capacity. You may be discussing colonies of ants but this applies to any social organism which does, of course, the human species. Individual human beings, like individual cells in the body of an organism, are unaware of the 'collective consciousness' which they belong to, though strictly speaking to call it a 'collective consciousness' is a misnomer, because means self-aware and we are only aware of its existence, if we may call an emergent property of a population as actually existing, members of society. Societies can include nations, cultures, families, hobby groups, fandoms, and whatever other communities any of us belong to, and institutions like the economy, political structures, governments, libraries, and the arts and sciences. Together they can be considered to form a human hive mind. of which we are no more aware than a neurone knows it is in a brain.
What makes the human hive mind sentient is that as individual human beings we respond to what is happening in our environment, social, economic, political, and physical, and when we respond and interact with other humans this eventually rises to the population level.
None of this constitutes something that is scientifically verifiable. It is purely a matter of interpretation. Although it can be viewed through the prism of evolutionary thought. Possibly as a sort of a supra-organism'. Fred Hoyle suggested in the 1950's or 1960's there could be a putative 'supra-organism' arising from the collective actions of human species. He called it the Thing. Calling something of this sort a hive mind, collective consciousness, group intelligence, or a social supra-organism are simply labels for an emergent property produced by the sum of history of actions committed by the individuals in a total population.
Hoyle's Thing was mentioned in either A Decade of Decision (1953) or Encounter with the Future (1965). A quick flick through my copies of these books didn't confirm which it was, so I apologise for not being able to give the correct reference.
Basically in answer to the OP's question, the same selective pressures that favour the evolution of social organisms, will favour the evolution of a 'collective consciousness' (even if collectively it is unaware of itself, so hive minds can be collectively unconsciousness but still function as social intelligences). Social organisms simply function that way. Any text on evolution discussing the formation of social species is in effect discussing the evolution of the collective intelligence of those species. Strangely enough, it's nothing that special.