My son, do not despise the Lord’s discipline or be weary of his reproof, for the Lord reproves him whom he loves, as a father the son in whom he delights.
-Proverbs 3:11-12 ESV
It may seem strange to think that the Lord reproves those he loves, but it makes more sense when you look at this concept in the light of parenting your own children. If you are disciplining your children for the right reasons, you are doing it not out of anger, but out of a desire to help your children improve.
So it is with God, who reproves us only because He wants to see us improve.