The righteous seem to receive all of the bad things, and the wicked seem to go through life unscathed, untouched. They have the big cars and the nice houses on the hill. They can take fancy vacations. Nothing bad ever seems to happen to them.
A main reason that I Peter 2:18-24 was written is to warn us that sometimes the innocent are caught in God's justice. They will have to suffer for something that they have not caused. The test for us is whether we will be able to accept God's justice, His judgment, and take it in the same spirit that Christ did. If anyone could ever cry out, "Unfair! Unfair!" Jesus Christ would have to be the One.
How about us? What trials have we gone through, in which we did not cause the trial but became caught in somebody else's sin? It is very easy in such cases to cry out to God, "Unfair! Unfair! God, why are You allowing this to happen to me?" The implication of our complaint is, "After all the good things that I've done for You, God, You treat me like this." We are, in effect, trying to vindicate ourselves. We become frustrated and accusative, never even stopping to think that, if we received truly fair treatment, we would get what happened to Nadab and Abihu and Ananias and Sapphira!
God wants to see if we have faith in His judgment, in Him as an absolutely perfect Judge. Do we trust Him, or do we only trust Him when the going is good?