I know I've heard this before, and I've not taken an evolutionary biology class before so I do give a lot of weight to the idea that there is little influence at the group level, but one of the first paragraphs states: "As of yet, there is no clear consensus among biologists regarding the importance of group selection."
In particular, when selecting for war, there's a clear individual level selection pressure: if you don't cooperate with your group, you likely die. This is a just so story, I have no idea how irrationality actually developed, but say you have small groups of hunter gatherers and one individual develops a preference for cooperating in raids against their best interest. If this means that on average you now have two versus one whenever this individual participates, there's a clear competitive advantage which could allow that gene to propagate. The key here in this hypothetical is that the mutation occurs at the individual level in a lone individual, who then cooperates with someone else who wouldn't necessarily follow them, but is happy to have the help. This results in a disproportionate gain (100%) in effectiveness vs lone opponents. As time evolves, the gene becomes more widespread by its early disproportionate effectiveness and groups that fail to cooperate are killed on average, thus eliminating individual competitor genes.
Again, I have no idea how war actually evolved, but it seems easy to believe that when a trait influences whether one group kills another, that it would cause the killers to have a reproductive advantage. I'd love someone more educated on this topic to send me up though.