One frequent defense made on behalf of religion and theism is the claim that they are necessary for morality. This claim takes a variety of forms: people wouldn't behave morally if it weren't for religion or fear of gods, some god or gods are the authors of morality so we can't be moral without following their commands, religion and gods provide reasons to be moral, the absence of religion or gods encourages immorality, a moral person is simply assumed to be religious, and so forth.
Whatever the form, though, the principle is the same: religion generally, or some religion in particular, is equated with morality to the extent where they can't be separated. Sometimes this will be offered as a pragmatic reason for adopting that religion by arguing that even if the religion seems implausible, it's still useful by promoting morality, and this should be encouraged broadly in as many people as possible.
While these claims may be intuitively appealing to many religious theists, just how well-founded is the belief? One means for testing it is to look at the religions themselves. Are their gods moral? Are highly-regarded believers from the past or religious figures in scriptures moral? Are believers today especially moral? The answer to all of this is overwhelmingly negative, and this creates a reason to doubt both the claims about religion being necessary for morality as well as the fundamental truth claims made on behalf of the religion generally and theistic claims in particular.
The gods people have believed in certainly have not been especially moral in their behavior. This was abundantly true in ancient polytheistic religious traditions, such as the Greek and Roman gods, but at least no one made grandiose claims on behalf of their gods' morality. Not a great deal has changed, though, with modern gods. Christians, Jews, and Muslims all believe in a god which their own scriptures describe as having been the cause of tremendous suffering and evil things which, if any human did, would cause that person to be reviled as the most evil person in history. Many of these acts are carried out by figures in religious scriptures, making them just as culpable as the deity who gives the orders.
One example would be all the killings which the Jewish god orders throughout the Old Testament pretty standard stuff for that time period, but not exactly appropriate for a perfectly good and just deity. Another example would be the very principle of salvation behind Christianity: people who deserve some sort of punishment are let off the hook by punishing a completely innocent individual, and if people don't accept this then they are destined for an eternity of torment regardless of the scope or seriousness of their misdeeds. Neither side of that equation is the least bit moral.
Because it's a god that's involved, however, the actions are suddenly defended as just or righteous. No independent standards of morality are used here; instead, who the actor is becomes the determining factor. This sort of attitude has, I think, made it easier for believers throughout history to rationalize their own immoral behavior. Wherever we look, we can find people insisting that because they are acting on behalf of their god or their religion, their immorality suddenly becomes morally righteous. Augustine defended torturing heretics because "many have found advantage...in being first compelled by fear or pain, so that they might afterwards be influenced by teaching..."
Fortunately today, many if not most religious believers have gotten better. People who, like Abraham, claim that their god has ordered them to kill their children are treated as insane rather than as models of perfect faith to praise. No one seems to recognize the problems this switch creates for their religion, but it's still a step in the right direction. Those who, like Augustine, seek to argue that people with the wrong beliefs should be tortured and perhaps killed will likely end up in jail as criminals rather than leaders of their religion.
This does not mean, however, that religious believers today have gone far enough. They still continue to believe or do immoral things, often justifying their immorality on the basis of what they say their religion requires. Too often, society gives such behavior a free pass, allowing people to do things on the basis of religion which wouldn't be allowed in purely secular contexts. People will, for example, deny necessary medications to their children on the basis of religious faith or teach their daughters that they must live their lives subordinate to the men in their lives.
In theory, this shouldn't matter after all, irreligious atheists also behave immorally, sometimes justifying immoral actions on the basis of secular philosophies. So what's the big deal? The difference is, no irreligious atheists try to claim that their secular philosophy is a divinely created or even just divinely inspired system of morality. They don't deny that their morality is human and therefore quite flawed. The presence of flaws doesn't cast doubt on the origins or nature of a human-created, secular philosophy; it does case doubt on the origins and nature of a system of morality which allegedly comes from a perfect god.
None of this proves that no gods can or do exist, nor does it prove that no religions could be or are true. It does, however, make it unreasonable to single out any one religion as true while treating all others as false. When a person claims that their religion, and their religion alone, is true, comes from the one true god, and contains the one true morality created by that god, then it's hard to treat them as credible when their religious system is invested with so much obvious and rationalized immorality.