Bora Zivkovic believes religion evolved to encourage group cohesion:
For the group cohesion to work, one HAS to, by definition, feel that one's group is superior to all other groups. This sense of superiority is enhanced by the additional "attachments" that may differ between different religious traditions, e.g., the belief in an inerrancy of the leader who gets orders directly from the group's omnipotent god(s), various trance-inducing chants and dances, behavioral rules, sacred books, etc. All of these also promote internal policing by the group - those of "weak faith" are detected and punished mainly by other members, not necessarily by any kind of official armed forces, though some groups may use the latter as well.
So that's how the Republican party machine works.