But, it is also the case when something bad happens. We have this insatiable need to define the exact cause and fully understand why. Now I am not suggesting not exploring it and learning from it. After all, in manufacturing, I taught the Japenese notion of "Poka-yoke". The idea that you fix something so that it doesn't ever happen again!
But, with life it isn't always that simple. I believe that by living by biblical principles, you set yourself up to succeed. However, sin still exists and evil can still have its way.
Joseph's story in the Bible is a clear example of where faith should enter our lives. Joseph didn't know the Upper Story, God's intentional will for Joseph's life. Joseph just kept his faith in Yahweh and over time, God continued to reveal himself. Pretty soon, it was clear that what his brothers intended for evil, God worked in for good. Joseph's brothers failed, but God still prevailed.
So it is in our life. I fail often [unfortunately], but God still uses me to accomplish his will. My prayer has always been "Lord, let me work where you are working. Let me get out of your way. Use me to be an instrument of your love, grace, and mercy. Amen"
In the end, where I fail, God will INDEED prevail.