This has been an ardent belief of mine since I was a teen and it still is 45 years later. Even my partner has come to believe the same thing, that if something seemingly unfair happens, it's for his/our own good. I, and for the past 3 decades, he, have learned to pay attention to the little set backs in life that have ultimately led us to better lives than we had before so we pay close attention and trust that God watches over us, no matter the stupid things we sometimes do.
Our lives always improve because that is how God wants it to be. And who a I to question God?