I would warmly recommend the last chapter(s) of 'The Selfish Gene'. Now an aged book but still largely up to date. In those last chapter(s) Dawkins invented the word meme as analogy to gene: a meme is a self-replicating piece of information. Like genes that are successful (in the environment they are in) propagate so do memes that are successful. Religion is the ultimate meme complex, it is a set of ideas that lives 'on top of' us and as long as it doesn't kill its host it may spread further.
In that sense, while I would guess at minimum religion can't kill its host, it does from this logic not necessarily benefit the host. An aggressively missionising or crusading religion might outcompete one that is peaceful and better for its host. And even a peaceful variant (see original Buddhism or zen Buddhism) might evolve into an aggressive, exclusive and murderous ones (see Buddhist monks in Myanmar firing up and demanding the genocide of the mostly muslim rohingya ethnic group).