The way I view religion, it has to have one or more conscious entities controlling the universe. I don’t know that it necessarily has to include a code of behavior, but religions almost invariably do. There’s also frequently an overriding sense of fairness, that people who do good will be rewarded and those who do evil will be punished. Really, the fact that I don’t see much evidence of this being true is part of why I’m not so keen on religion. I WISH it were true, but where’s the proof? That said, even if true fairness and justice don’t exist, they are ideals toward which we can and should strive, and I’m sure most of us can agree on this despite our religious or philosophical beliefs. Well, maybe not Glenn Beck, who claims to look down on “social justice.” Isn’t justice social by its very nature? Slacktivist had a good post on this subject a few years ago. Anyway, within religion, the fact that real life often ISN’T particularly just is often tied in with the concept that your earthly life isn’t all you have. Some teach of life after death in a paradise or place of endless torture, while others have your deeds influence the form in which you’re reincarnated.
Within Indian religions, the cosmic sense of fairness can be expressed in terms of karma. Everyone thinks they know what karma means, but in popular usage its actual significance is frequently diminished. While “if you do something bad, bad stuff is going to happen to you” can be a PART of karma, it’s not all there is.
I’m no expert on the subject, but from what I’ve heard and read it’s more the idea of cause and effect in general, and how it can relate to the individual. There isn’t necessarily a one-to-one correspondence between an action and its consequence, but the karma you accumulate will eventually affect your fortune. If there are mathematics involved, the cosmic accountants aren’t going to let us see them. Karma could, perhaps, be said to be linked to Newton’s Third Law of Motion, albeit on a moral and spiritual level rather than a purely physical one.
I’ve heard before that Hindus consider even the gods subject to karma, but the subject of what makes a god in Hinduism is a quite complex one. Apparently some Hindus think that the ultimate god is not subject to karma, and indeed is the one who controls it. The position taken by modern monotheistic religions is often that God, being the one who CREATED the laws, is not subject to them himself, but not everyone agrees with this. Just today I caught a little bit of Joel Osteen insisting that God plays by rules. Mind you, the rule he mentioned is that bad things will happen to you if you expect them to, which sounds a little more like The Secret than the Bible, but whatever. If God is truly omnipotent, then he’d presumably only operate under any kind of law because he wanted to. As I’ve pointed out before, though, if God came up with the idea of what justice and fairness are, why doesn’t he always act just and fair by the standards he gave humanity?
Many classical gods clearly have their limits, as seen in the idea that the death of the gods at Ragnarok resulted at least partially from their breaking oaths, particularly the one they swore to the giant who built the never-completed wall around Asgard. Oaths are also important to the Greek gods, inasmuch as Hesiod claimed that any deity who broke an oath on the River Styx would be punished by being forced to lie around insensible for a year, after which they’d be banned from Olympus for a further nine. This might well reflect the ancient Greek view of exile being pretty much the worst imaginable punishment. The penalty was apparently prescribed by Zeus as a reward for the nymph of the Styx helping him out in his war against the Titans, but I don’t know whether he himself was subject to it.