Religion gives many people a framework and community that reinforces moral behavior, but plenty of atheists are kind and plenty of believers are cruel. It's a useful tool, not a requirement.
Religion undermines morality by excusing hate and violence as divine will, like crusades or anti-LGBTQ bigotry. It distorts ethics more than it helps.