Religion was born out of the fear of death. Death is the one insoluble human problem. It strikes fear into the hearts of all people. We would do anything to make it go away, including inventing supernatural beings who promise everlasting life in some distant and invisible kingdom. And, seeking solace, we would fiercely cling to that belief. In the act of worshiping gods you and your family might survive a little bit longer and live a bit better. The world was full of dangerous and inexplicable things like storms, floods, droughts, volcanoes etc. It was attractive to suppose that there were individual human-like beings causing them, particularly if you could influence them in some way (e.g. by sacrificing an animal, or by just telling them how wonderful they are very often).
In the whole animal kingdom, we humans are the only creatures aware of death. “The fear of death is worse than death,” wrote Robert Burton, in The Anatomy of Melancholy (1621). Long before this, Aristotle had argued that we should learn to accept death as a part of life. The simple view held by most atheists and humanists, and myself, is that once dead we are dead, despite the fact that more than half of the public in the UK and US believe in life after death, for which there is zero reliable evidence. Reports of near-death experiences, which are quite common, are essentially mystical, and tell us nothing about death itself. Fear of death occurs in some children as young as three years old. But very young children think of death as being like going to sleep, not as something final.