David S. Wilson and Edwin O. Wilson write a very clear summary in American Scientist, with title of this post, of the main features of group selection theory - which describes how natural selection takes place at multiple levels: genes, individuals, group of individuals. Below is an excerpt, and here is the PDF.
To think clearly about group selection, it is important to compare the survival and reproduction of individuals in the right way. The problem with "for the good of the group" behaviors is that they are locally disadvantageous. A prudent member of the herd might gain from conserving resources, but cheaters within the same group gain even more. Natural selection is based on relative fitness. If solid citizens are less fit than cheaters within their own group, then something more is required to explain how they can evolve in the total population. That something is a positive fitness difference at a larger scale. Groups of solid citizens are more fit than groups of cheaters.
Figure - Multilevel selection theory describes a hierarchy of evolutionary processes organized like nested Russian dolls. At the innermost level, within a single organism, genes contend with each other for a place in the next generation; within a group of organisms, selection acts on the relative fitness of individuals; groups within a population also differ in their collective survival and reproduction. Adaptation at any given level tends to be undermined by selection at lower levels. At even higher levels (not shown), populations, multispecies communities and whole ecosystems can be subject to selection.
These interacting layers of competition and evolution are like Russian matryoshka dolls nested one within another. At each level in the hierarchy natural selection favors a different set of adaptations. Selection between individuals within groups favors cheating behaviors, even at the expense of the group as a whole. Selection between groups within the total population favors behaviors that increase the relative fitness of the whole group—although these behaviors, too, can have negative effects at a still-larger scale. We can extend the hierarchy downward to study selection between genes within a single organism, or upward to study selection between even higher-level entities. The general rule is: Adaptation at level X requires a corresponding process of selection at level X and tends to be undermined by selection at lower levels.
This way of thinking about evolution is called multilevel selection (MLS) theory. Although the term "multilevel selection" is newer than the term "group selection," the Russian-doll logic has been present from the beginning, going back to the works of Darwin.
Darwin would not have been motivated to think about group selection were it not for the existence of traits that are selectively disadvantageous within groups. In a famous passage from Descent of Man, he notes that morally upright people do not have an obvious advantage over less-upright people within their own "tribe," but that tribes of morally upright people would robustly outcompete other tribes. He concluded by saying "... and this would be natural selection." Darwin was clearly employing the Russian-doll logic of MLS theory in this passage. He did not comment on the irony that morality expressed within groups can become morally problematic in between-group interactions, but his hypothetical example perfectly illustrates the general rule stated above, which makes adaptations at one level part of the problem at higher levels.