Anyways, I wanted to offer the suggestion that the Chumash (the five books of Moshe) offers support for this idea but rather than it being something hypothetical, it has a very down to earth meaning:
The selling of Yosef. Why did the brothers sell Yosef? According to the explanations of our Rabbis, collectively Chazal, they were trying to purify the Jewish people of a potentially corrupting influence. Just as Esav and Yishmael had been weeded out of our genepool early on, the brothers mistakenly thought Yosef, who was sewing strife, also had to go.
We all know the outcome of the story: Yosef is sold down to Egypt, where he becomes second-in-command to Pharoah and, in practice, rules over the entire land of Egypt. The upshot being that when the whole world is soon struck by a famine of biblical proportions, (pun intended) Yaakov and his descendants are provided for by their long lost son and brother, Yosef.
In this story we see a clear representation of an action, taken for the best of reasons, bringing about a positive result.
The important part of the story to note is that even though the brothers themselves regretted their actions and thought they had caused no end of damage, in reality, because they went into the initial action with good intentions, HaShem made the end result itself good. This is the true meaning of "HaShem casts good intentions as [good] deeds."
We have to learn from this too: Even when something blows up in our face, and we have no recourse, no way to understand what to do now or how to put the pieces back together, we need to have faith in HaShem: We went into it with good intentions, let's wait and see how this is going to turn out for my good as well as the good of everyone else.
How many times have we heard stories of small or large setbacks that lead to sudden miraculous salvations? How many times has research gone awry only to deliver some amazing new discovery? You could say, still those times are the exception, not the rule.. but how many more situations could have been new beginnings had we been open to the possibility?
Another important point, while addressing the story of Yosef's sale is Yosef's own response to all this: The Ohr HaHayyim (R' Hayyim ibn Attar) explains that Yosef tells his brothers: "Even at the time of the sale, you were still my brothers in my eyes." Even in the midst of the troubles that befell Yosef, he always looked to the good that would come of it--he knew he would be reunited with his brothers and he didn't let their current actions get in the way of the deep bond he had with them.
This is something we can all learn from: Sometimes people we love act stupidly or selfishly, more often their actions seem stupid and/or selfish until we arrive at their point of view and understand the logic, often even benevolent intentions, previously masked by our own ignorance.
First: give your loved ones the benefit of the doubt, assume they don't mean to be hurtful or even if they do, assume that they are so hurt themselves that they can't even think clearly right now.
Second: If you don't let go of your love for them, in the end they'll come around, all wounds can be healed.
So we see how these two forces, the power of good intentions and the steadfast commitment of love can turn the worst most ruinous moments of a relationship into the deepest sweetest miracles of life.
[There will always be skeptics and pesimists, but they live life alone -- that's the answer to the question presented at the beginning of Plato's Republic.]