Right Place, Right Time, Wrong Reason

"Vaarsuvius: How will I achieve complete and total ultimate arcane power? The Oracle: By saying the right four words to the right being at the right time for all the wrong reasons."

- 'The Order of the Stick 331'

Some characters have very bad flaws. They could be perverts, cowards, bigots - but sometimes these "flaws" actually turn out to be very fortuitously beneficial. You see, since Johnny was a cowardly, bigoted pervert, he ran away in fear from the first black dude who just happened to be walking down the street while he was watching a woman take her clothes off. As a result of his haphazardness, he crashes right into a supervillainess making her devious escape from the superhero. And so, all is right with the world.

This trope is when this event comes up in fiction - only there, expect our cowardly, bigoted pervert to be given a stern lecture on why those are such terrible character traits. Naturally, this turns into a pretty serious Broken Aesop when we've seen the villain in question kicking puppies - and all our heroes are naturally completely absent of such negative character traits.

Where this trope works best is when the writer doesn't call attention to an Aesop, and the coincidence just becomes something "that happens".

Comic Books

 * In Elf Quest, Rayek is able to guard the spirits of all the elves who die in the destruction of Blue Mountain. The reason he is at Blue Mountain at the time, though? Hot sex with the Big Bad.

Film

 * In Back to The Future, it turns out that the only reason Marty's parents got together is that his dad just happened to be a peeping tom. Marty is notably distressed by this, particularly since it looks like Marty's mom would get together with whoever got hit by a truck that day.
 * A big one happens in Pan's Labyrinth. Seriously. The Chessmaster couldn't've planned a better strategic turn of events than that.
 * The killer from Rear Window would have gotten away with it if it weren't for the hero's voyeurism.

Literature

 * In the Discworld books, as the favoured of The Lady (luck) this is pretty much Rincewind's way of life. He's saved the Disc several times over, mostly by running for his life and stumbling into the villain's plans. You can count the amount of times he acted bravely on purpose on one hand.
 * Ciaphas Cain also owes pretty much his entire career to this trope. The Emperor appears to have it in for him because almost every act of intended cowardice, self-preservation/gratification or caution on his part ends up being turned on its head and landing him smack dab in the middle of another life-threatening situation. Then again he always manages to survive it with flying colours, so the Emperor might just be doing it because he knows he can take it.

Live Action TV

 * 24, as per the parody.

Video Games

 * In Metal Gear Solid 4 Guns of the Patriots, series Butt Monkey Johnny Sasaki turns out to be immune to the nasty side effects that arise when the nanomachines are shut down by the Big Bad, and this later allows him to have a Big Damn Hero moment in rescuing Meryl, all because he never got the nanomachine injections in the first place. Meryl asks him how he knew something like Liquid's hijacking of the system would happen, and Johnny says he didn't. He was just so afraid of needles he avoided all the mandatory injections.

Web Comics

 * Both of the non-Good-aligned party members in Order of the Stick:
 * Vaarsuvius does this a lot. First, s/he kills Kubota, who was unarmed and tied up, but was probably going to get away with murder and attempted assassination, simply because V (correctly) guessed that he was a minor villain and was tired of distractions. Later, V, which s/he did mainly because s/he was tired of feeling powerless and wanted ultimate arcane power (an oracle even uses the trope name when predicting this event). After gaining said power, V then   because s/he was tired of dealing with them. V then  , which may ultimately be a good act, but s/he did it mainly out of a (justified) grudge and to prove that s/he could. Lastly, s/he attempts to , not because he's Evil, but to prove that s/he is the strongest magic user in the world.
 * Belkar is basically a sociopath who never thinks of anyone but himself (and probably his pet cat), but usually his bloodlust is directed at Evil beings. He is always puzzled when others express gratitude for his actions and repeatedly Lampshades that he can loot and murder all he wants as long as his victims are the right species.
 * In a variation, Eugene Greenhilt desires the Right Thing for the Wrong Reason: he wants his son to kill the evil lich Xykon, but only so that the family blood oath can be fulfilled and he can get into the afterlife. He lords this over Roy at one point: he cannot in good conscience not do the one thing his father wants, so he has no way of bargaining with him.

Western Animation

 * In one episode of South Park, Cartman decides in prejudiced irrationality that the new Arab student is a terrorist and pulls out all the stops to save Hillary Clinton, who, coincidentally, is in South Park that very same day. Even though Cartman's theory is completely unfounded, it turns out that there are terrorists plotting to kill Hillary Clinton (Russians secretly working for )--but the only reason we found out about them is thanks to Cartman's prejudice. This is Lampshaded heavily at the end, when they deliver the story's moral about tolerance only for Cartman to point this out.
 * In "The Mermaid Queen", an episode of Winx Club, it's repeatedly mentioned that one of the one-shot characters in this episode has always been afraid of everything. Having practically let the season Big Bad attack her kingdom and kidnap her mom (the titular queen), she feels ashamed of this, so she swears to be more brave as she's freeing her mom while on a rescue mission with the Winx. The problem here is that everyone who actually fought the Big Bad became one of his minions, so it was only because of her cowardice that there's anyone left to even tell the Winx about this so they could mount this rescue mission. Source.
 * Homer is cleared of indecent assault in The Simpsons by dint of Groundskeeper Willie capturing the real course of events on camera during his activities as a peeping tom. Willie is then dragged through the mud the same way Homer was.
 * Additionally, Bart once witnesses events relevant to an assault trial only because he skips school. The episode deals with his turmoil about knowing the suspect is innocent despite overwhelming evidence, but realizing that he'll be in huge trouble if he reveals the truth.