It is for your blessing, that you would share in God's holiness and produce the fruits of righteousness and peace. God is training us, the way a coach trains and disciplines the athletes under his care. A coach stretches and pushes and exercises his athletes, so that they run their race with endurance. Training is no fun at the time. No one likes it.
Training is often painful and unpleasant.
He's training us for righteousness, disciplining us to run the race set before us, stretching and strengthening our faith in Christ. Sometimes God disciplines us because of our sin. He disciplined Israel who disobeyed Him in the wilderness and let a whole generation die without seeing the promised land. Or King David, when He permitted the child conceived out of David's adultery with Bathsheba to die the day before his circumcision. Or the congregation at Corinth, some of whose members got sick and died for eating the Lord's Supper while despising the body of Christ in the Sacrament and in their fellow congregation member.