In general, positive actions (such as helping people and being generous) lead to good experiences and happiness, while negative actions (such as harming others and being deceitful) lead to bad experiences and unhappiness.
A hallmark of most major religions is that God is omniscient, that he knows everything. He knows the future as well as the present and the past. This has spawned many an argument over the extent of free will.