Like many things that have evolved over time, the God concept has several uses, and it is not possible to say which is the one it was invented "for". As a vehicle for explaining morality (Why not kill? God says not), as a means of keeping people under control (do what the priest says, or God will punish you), explaining the unexplainable (God makes the sun rise), palliating the fear of death (God will take me to heaven, if...), providing a mechanism for attempting to solve the unsolvable, or at least doing something (prayer), providing a forum for happy singy dancy ceremonies (worship). It serves all these purposes separately, and which is the most important varies between people.