In Christianity, for example, Heaven is the reward for following society's rules, and Hell the punishment for ignoring them. In societies where rain is rare and its presence ensures the continuation of the society, worshipping a rain god reinforces the common need for rain and presents a way that all members of the society can work together to produce that thing most needed for its survival. In the Greek and Roman religions, there was a different god or goddess for every virtue, vice and need. One could pick and choose which deity to worship based on what was needed at the time. This helped them to focus on that specific need to the exclusion of other needs, thereby making that need increase in importance.
Religions change as societies change.
In the Old Testament, the Hebrew god was authoritarian, paternalistic and warlike. These were important qualities for a nomadic people trying to find and keep their place among other wandering tribes each with their own deities. The Romans had control over the Jewish people and Jesus represented the need to remain true to the Jewish faith and to struggle against Roman domination. The Jesus and god of love are a fairly new creation. It is probably a reaction to the desire for all of the evolving countries of Europe to get along instead of killing each other off.