 Judaism teaches that all willful sin has consequences. The completely righteous suffer for their sins (by humiliation, poverty, and suffering that God sends them) in this world and receive their reward in the world to come. The in-between (not completely righteous or completely wicked), suffer for and repent their sins after death and thereafter join the righteous. The very evil do not repent even at the gates of hell. Such people prosper in this world to receive their reward for any good deed, but cannot be cleansed by and hence cannot leave gehinnom, because they do not or cannot repent. This world can therefore seem unjust where the righteous suffer, while the wicked prosper. Many great thinkers have contemplated this.
<coherence>  Judaism teaches that all willful sin has consequences. The completely righteous suffer for their sins (by humiliation, poverty, and suffering that God sends them) in this world and receive their reward in the world to come. The in-between (not completely righteous or completely wicked), suffer for and repent their sins after death and thereafter join the righteous. The very evil do not repent even at the gates of hell. Such people prosper in this world to receive their reward for any good deed, but cannot be cleansed by and hence cannot leave gehinnom, because they do not or cannot repent. This world can therefore seem unjust where the righteous suffer, while the wicked prosper. Many great thinkers have contemplated this.