Natural selection works on the population, rather than individuals to allow the maximum number of survival.
Honeybees are an example of a social organism that lives together to maximize survival. They are divided into three groups: queen, drone, rearing larvae. The queen is responsible of reproducing and the others are responsible for other jobs including finding food and protecting the shelter. This behavior can be described as being altruistic since infertile female and male are working for the queen without a clear benefit.
Although altruism contradicts survival at the individual level, it may help survival of the whole population, and thus is sometimes valued evolutionarily.