Anytime your morality must come from an external source based on ego of some sort, it's going to get twisted. What do morals do? really they make for a stronger society, healthier society. The dogma of religion, specifically the big three from Abraham, dabble some of this in with a lot of nonsense. Being kind to your neighbor, being a decent person, those things get lost in religions idea of right and wrong, then you have extremists committing great wrongs. Because YHWH, God, Allah always includes a 'but' or 'if'. It gives a loophole for great evils.
"Religion is an insult to human dignity. With or without it you would have good people doing good things and evil people doing evil things. But for good people to do evil things, that takes religion."-Steven Weinberg