With or without religion, good people can behave well and bad people can do evil; but for good people to do evil—that takes religion.
I take religion to mean dogma, or anything taken to be true without verifying by experiment or experience. I differentiate between theism and religion. (Sadly most scientists, including Weinberg himself, don't seem to.)
I came across this quite some time ago. It seemed intuitively true even then, but yesterday, I pondered over why the same religion won't make bad people do good things.
We need to consider the nature of normal bad people. What we mean when we say a person is bad, is just that they are extremely selfish and short-sighted. Selfish here could include placing one's own kin or cult or country above any other too.
Good people, on the other hand, give consideration to others' feelings and also to long-term results of their actions.
Now, dogma can tell you that dogs love getting their ears clipped, but it can't tell you you'll love to get your hands amputed. Dogma can tell you if you give a hungry man a meal (how do you tell he's hungry anyway?), you will reap a tonne of grain fifty years from now -- or go to heaven after you die, but it can't tell you a sack of grain will appear in your kitchen at the very moment.
Dogma can tell a Briton that India is a land of elephants and snake-charmers, but can't tell them that Britons are very tactile people who hug others at least 20 times a day.