RPGs are a crazy medium for story telling. Not only do you not have one story teller with control over what is happening, but you regularly end up in situations where nobody has control. That means things go off the rails sometimes. When you factor in the supposed competency level of the people involved, it's hard to say if things go pear shaped more often in fantasy as they do in the real world. Still, if nothing else all this means one thing: no matter your plan - be you a GM or a player - there is a good chance it is going to fail, and it won't even be anybody's fault but dumb luck.
Escaping A Slave Ship
In a Star Wars game I am in, the GM started things off with the PCs being taken in by a group of "honorable" slavers. I say "honorable" because the group had redeeming qualities. If you had skills they needed you could work. Work off your cost and you could even leave. Didn't change the fact they were slavers, but it meant there was room for the players to work at securing their escape. Then, one session, we ended up a few players down and the players that were there all came to an agreement on a plan to escape.
The idea was simple. The pilot kept a ship ready. The mechanic/hacker got the way ready and compromised pursuit. Finally, the social character with the highest rank, was to make sure that all the PCs were on board along with some NPCs that had been caught with us, and the other slaves would have a chance to stage their own escape with as much initiative on their side as possible. It was a good plan, for a quick one, and we went for it.
Then tragedy struck. Through a series of rolls at a key moment the social character ended up not only being caught out (despite the fact his social pool should have wrecked his interrogator), but starting a fight before he could get the other PCs armed or do any of the things we needed for a "quick and quiet" escape. Things went to chaos. PCs acted. NPCs reacted. Things went even further to chaos. In the end the PCs did escape, but the ship was left in a full on slave revolt where the slaves didn't have access to the firearms meaning we left behind a very bloody fight and got a lot of people - some of whom's only crime was they didn't want to be slaves themselves.
Not exactly the best way to start off in a game where the PCs are supposed to be reluctant heroes, but still heroes. Huh?
So What Happened?
I mentioned it in the description, but I want to be clear. Neither the GM, nor the player, did anything wrong, subversive, or off plan/script to set things off. The NPC who talked to the PC was supposed to be there, and was a known obstacle. The PC tried to get past socially and tried to use all the right cards to play. Perhaps - and I mean perhaps - some of the phrasing could have been better, but our group has never been one to call someone on the exact phrasing of what they said.
No, what happened was a character with - to simplify things - a +10 in deception failed to deceive someone with a -2 to avoid being deceived. Perhaps not that starkly out of favor for the NPC, but still a clear enough situation that the PC should have won the check, and most certainly should not have failed three checks in a row.
Sometimes Sh!t Happens
This is a fact for any RPG. By the rules, at any time that a PC has a chance of failure, and that failure is significant and can change the story, we have to roll dice. This die roll is meant to simulate the random chance involved in the situation. The myriad factors that come into play from factors we don't know (did they see you set your plan up?) to things we can't explain (a random hunch or reasonless dislike.) It works well enough for a game, though I would argue that I have yet to see a system have a random number based resolution mechanic that adequately shows the reliability of someone being better, but that is neither here nor there.
The point is, if you play RPGs, sometimes bad dice rolls are going to happen. Sometimes amazing dice rolls are going to happen. And yes, when these rolls happen, it's going to mess up your plans. It could be as simple as the non-duelist low honor Lion Duelist destroying the Master Duelist and thus not getting 'taught' the lesson you wanted the character to learn, or it could be as major as a PC fumbling and throwing the Vorpal Sword needed to kill the Jabberwocky into a fast flowing river right as the fight is about to begin.
Handling Low Probability Events
What do you do when this happens in your game? The best thing to do is be prepared. This seems odd, but when you're going over your plans for the game try to think of some ways things could go wrong. What if the player with the key item to pass a fight doesn't join the fight? What if the lynch pin NPC is not convinced to join? What if the players just charge the enemy hordes instead of taking shelter in the keep where they'll have defenses to help them hold out against the larger than expected number of foes before them?
Next, you need to be able to think on your feet. Your PCs will be trying to do this as well, so be ready. As a rule never have only one way to deal with a problem, and don't define all the ways either. If a player has a particularly clever idea you want to be able to reward it, not let them expend all the effort just to go "yeah, sadly that was doomed from the start."
Above all, remember that this is a game. Losing is a possibility, and that's fine, but you also can't count on the players going the 'exact' right way. Most stories hinge on key "big rolls" at key moments. In the book Luke Skywalker rolls a nat 20 and sinks the two proton torpedoes down the exhaust port. In the RPG he's just as likely to roll a 1 and miss, or something not a 20 and not have it blow up the Deathstar in time. Know this. Plan for it. Don't just give Luke one shot to get it right, but let him - or her - feel like they got it just in time when and if they do succeed.
Be prepared to bend. Be prepared to flex. Make it fun. Above all, be ready.