The way I read it, Jonah hated the people of Nineveh, who were Israel's enemies. He didn't want to go and preach the warning to them in the first place, which is implicitly why he fled in the opposite direction and had to go through that whole business of being thrown into the sea and swallowed by the fish. Then when he finally did obey God and he went to Nineveh and warned the people that they were about to be destroyed, and they all genuinely repented and God spared them — well, Jonah was appalled. He didn't think these people actually deserved the Lord's mercy! As we're told, he was angry enough to want to die.
That's where the little lesson of the plant comes in. God provides a plant to shade Jonah, then sends a worm to eat it and it dies away. Jonah now becomes angry that the plant has died. But as God points out to him, Jonah didn't do anything to make the plant grow, yet he feels sorry for it — so how much more should God care about the people of Nineveh? I think it shows that God's compassion ranges far wider than we imagine and we should never think anyone is unworthy of His love or incapable of turning and being saved.