Psalms 119:71 (KJV)

It is good for me that I have been afflicted; that I might learn thy statutes.