Religion is mental sauve for an uneducated mind. It is a way for humans to 'feel' like they have control over all the huge things that kill them in the world by 'praying' or 'sacrificing a virgin' or 'offering fruit, meat, hair, animal sacrifices'. Since humans couldn't control floods they imagined a power, that looked like they do, that had the power over floods. And they then imagined if they offered this 'power' a sacrificed goat, which was extremely valuable when you only have two goats, then the 'power' or 'god' would have mercy on them and not send a flood. Extrapolate out to volcanoes, lightning, fire, bears, tigers, lions, crocodiles.
Modern religion serves the same purpose except over the last 3,000 years humans have learned they can manipulate the masses using this fear of a 'power' greater than themselves. And as humans that are in control do not like to give up that control which usually carries with it great wealth and choice of multiple females and thus carrying on ones genes, those in control nearly always side with the dominant religion and offer that group special treatment and physical dominance over other groups in exchange for keeping the masses medicated mentally. By default religion, even though on a personal level may help people in their lives, on a state level it is used as a boot on the neck of freedom.