Proverbs: 13:24: He who spares his rod hates his son, but he who loves him disciplines him promptly.
An earthly father disciplines his son or daughter by occasional spankings. In so doing, they learn to grow in discipline. In spite of corrections and chidings, the love of a father towards his children never grows old. He punishes his children to help them realize and understand right from wrong.
God loves His children. He corrects us when we go wrong. It does not mean that He hates us. God demonstrates His love for us through tests and trials. He allows certain things to befall us to discipline and teach us to obey Him wholeheartedly. We may love and worship Him but if we fail to obey Him, he dislikes it. When we fail to walk in His ways, He will ensure that we go back in His steps, sometimes through correction which might involve a light affliction and sometimes through a test or a trial.
When God disciplines us, we tend to grow in His upbringing and care. He does not always get angry with us nor does He always chide us. His anger lasts for a moment but His love lasts forever and ever. It is better for us to get disciplined by God than walk in our own ways like the sons of Eli and be destroyed.