Natural selection is simple in a sense, and it can rapidly get profoundly complex.
Natural selection is about the differential survival of variants of replicators in different contexts.
It tends to primarily work at the level of individual replicator, but can also work at the level of populations of replicators. Which effects dominate depend on the specifics of the context.
In one sense, evolution is always a context sensitive balance between order and chaos. Too much order, means not enough variation to survive the changes in context that inevitably happen from time to time. Too much chaos, and the necessary boundaries required to sustain the levels of complexity present fail, and the system dies.
At another level, there is a tension between competition and cooperation. If the threat to individuals comes largely from other things like self, then competitive strategies tend to dominate, and the system as a whole is driven to some local minima on the complexity landscape. If the threats are largely from factors outside of the population and there is something that can be done to mitigate them, then cooperative modalities can emerge, and be stabilised with attendant strategies to detect and remove “cheats”.
Rarely is any real environment all one or the other all the time, so real organisms tend to embody both sets of strategies at many different levels, and have some set of heuristic triggers that works well enough for the population to survive.
It seems that all new levels of complexity result from new levels of cooperative strategy.
It seems that in our evolutionary history many levels of cooperation have emerged. RNA molecules to allow for protein synthesis. Then RNA, DNA and proteins to form lipids and sugars and cells. Then groups of prokaryote cells to form eukaryote cells, then groups of cells to form bodies, then complex organs within bodies, then populations.
Anything with a brain sufficiently complex to learn behaviours and identify individuals then provided and environment for the emergence of a new level of replicators – memes.
In our cultural evolution memes seem to have gone through many levels of complex cooperative systems to produce most of what we know as culture and science and art.
It seems that any level of boundary that can deliver survival advantage to the group it defines, can be an agent in the multi-leveled process of evolution. And usually one level tends to dominate all others, and not always. Sometimes the situations are profoundly complex.
So there can certainly be genetic tendencies towards altruism in some organisms that express in some contexts, and there can be cultural tendencies towards altruism that can act in concert with the genetic, or can be entirely separate. And all of those tendencies will be the survival of something at one level, that appears to be altruistic at another level of being.
As human beings we are the most complex and cooperative entities we know of. And most of us can compete or punish cheats if the context demands it of us.
We seem to have the option of using technology to take this ability to cooperate to a whole new level, and our current reliance on markets to measure value seems to be the single greatest barrier to the emergence to such cooperation, as anything universally abundant has no value in a market.