In order to cooperate in the material worlds as agents of a divine power, the spirits temporarily have a material body. By the work required in their corporeal lives, the spirits improve their intelligence and, by observing God's law, they acquire the merits which will lead them to eternal happiness.
Allan KardecThe more clearly a principle is understood by the intellect, the more inexcusable is the neglect to put it into practice.
Allan KardecGod did not create the evil. He established the laws which are always good because he is good. The spirits would have been completely happy had they faithfully observed the law since the beginning. But, being free to make choices, the spirits have not properly obeyed them so that evil come as a consequence of this unwillingness. One can then say that good corresponds to everything which is in accordance with God's law while evil is everything which opposes it.
Allan Kardec