Peter is addressing people who were indentured servants (slaves) and instructing them how they ought to respond to unjust treatment. He points to Christ Jesus as the example to follow, pointing out that Jesus took an unjust beating for their just sins.
What a practical example to these believers who were indentured servants. How they must have related to Jesus work on their behalf. How gracious is our King that He would receive an unjust beating for us, who justly deserve the beating and scourging for our wicked behavior.
Thus Peter reminds them that they (we) were straying (prone to wander, Lord I feel it...), but by Christ receiving our punishment, the Shepherd and Overseer calls us back.
What a loving passage.
1 Peter 2:18-25
Servants, be subject to your masters with all respect, not only to the good and gentle but also to the unjust. For this is a gracious thing, when, mindful of God, one endures sorrows while suffering unjustly. For what credit is it if, when you sin and are beaten for it, you endure? But if when you do good and suffer for it you endure, this is a gracious thing in the sight of God. For to this you have been called, because Christ also suffered for you, leaving you an example, so that you might follow in his steps. He committed no sin, neither was deceit found in his mouth. When he was reviled, he did not revile in return; when he suffered, he did not threaten, but continued entrusting himself to him who judges justly. He himself bore our sins in his body on the tree, that we might die to sin and live to righteousness. By his wounds you have been healed. For you were straying like sheep, but have now returned to the Shepherd and Overseer of your souls.