In Chapter 2 of Jonah we find that even though Jonah was willing to die rather than preach to the Ninevites, God was not through teaching Jonah.
When we as humans are fully ready to “let them rot in hell”, God is still on the throne. It took a great deal to finally get Jonah’s attention and make him willing to carry out God’s plan.
Even after God spared Ninevah, Jonah sulked over the whole situation. His hatred had not yet abated. God still had to teach him another lesson. We will find that account in chapters 3 and 4.
But I believe that Jonah allowed this account to be written because he knew that the Israelites needed this message of the compassion of God on all peoples. (Of course, God wanted it in the canon of scripture as well.) And God wants us to recognize that we also need to have compassion for all peoples, even when the evil around them is all too apparent.
Let us examine ourselves and recognize that God had to have compassion on us or we would not be saved.
Romans 5:8 While we were yet sinners, Christ died for us.