God disciplines those He loves
Have you ever noticed that God uses both the carrot and stick approaches? In the Bible you find God challenging the Israelites with blessings and curses. Blessings if you obey and curses if they disobey. Rewards if we obey God and punishment if we don't?
God's example teaches us an important way to deal with those who are immature in their thinking such as children. God disciplines those He loves because He does not want us to go the wrong way.
Prov 3:11-12 (NIV) 11 My son, do not despise the LORD’s discipline and do not resent his rebuke,12 because the LORD disciplines those he loves, as a father the son he delights in.