The only reason religion has survived & thrived this long (and ever) is because of its deluded justification of violence. It completely and utterly defies logic but that does not matter when you are allowed to rape, pillage and destroy those who oppose. People mostly have no wish to die & will do almost anything to be accepted so will 'go along to get along'.. this is why Religion was invented - the concept was recognised then used to abuse
I think that's profoundly over-simplified. We have evolution (and spirituality seems to be our default programming), familial influence, hereditary, culture, upbringing, and so many other factors. Religion started before our prefrontal cortex was even an idea, so it's not fair to assume that those who use religion are somehow "deluded." Religion has its challenges, but assuming that the brain can work on only "logic" is also as crazy.