The book of Jeremiah asks a tough question: What happens when everything you believe in and live by is smashed to bits by circumstances? For anyone who believes in a God who is good, there is always the nagging wonder of why so many bad things happen to such good people. The book of Job, the oldest book of the Bible, presents this quandary as an odd little wager between God and the Devil. Job can't understand what is happening, but notes that "The Lord gives and the Lord takes away. Blessed be the name of the Lord." God never directly answers why, nevertheless Job says that he will maintain his trust even if slain by God. It is repeatedly emphasized that Job is blameless and has brought none of his misfortune upon himself. Jeremiah, on the other hand, in his defense of God's justice, puts a large share of the blame for human suffering on human sin and disobedience. Certainly turning away from God will have consequences, but what looks like punishment is not always the result of sin as Jesus explained to his disciples when they asked about the sin of the blind man.
As Israel faced a national tragedy of defeat at the hands of their enemies, Jeremiah proceeded to pronounce unpopular truth that got him banned from the temple and eventually stoned to death by his own countrymen. He at various times questions the value of sacrifice, circumcision, written law, the temple and the leadership structure of prophets and priests. For Jeremiah, religious reality was centered in personal communion with God. He spoke not of a new law, but a new motivation and accompanying power to fulfill the law that was already known (see 31:31-34). He emphasized a law that was written by God on the heart.
There's also an interesting parallel between Jeremiah and Moses. Both were born into a priestly lineage, but were called by God to do something else. Both tried to refuse the call. Both led their people for 40 years against stiff opposition. Moses led the people out of Egypt into the Promised Land. Jeremiah was forced from the Promised Land and wound up back in Egypt. This cycle of bad & good, losing & winning, pulling down & rebuilding, pulling up & replanting is actually included as a part of Jeremiah's divine commission (1:10).
Maybe the focus is on the wrong question. The fact that we have an innate sense that good people "deserve" rewards and bad people "deserve" to be punished might be the key. Where did we get this universal feeling that there should be justice? It's more than self-preservation, that's for sure. The words of Jeremiah implore us to pay close attention to the law that God has written on our heart.