We (not everyone) mostly believe in or pray to God only when we need him.
I think that God was made up by our ancestors in the beginning of life to explain things they couldn't and to look up to someone and to encourage others that there is someone watching over them, protecting them. That belief has been passed on through generations up to where we are today. But today, science has explained some stuff for which in the past, the only answer was God.
But religion and God is a good thing. People need something or someone to look up to, to believe in something, to believe that there is a Heaven or Hell. It's belief & religion that prevent most of us from killing others or doing anything else for which we might get punished in Hell for.
That's just my 2 cents.