Players hate to fail. They hate it even more if it seems like they were set up to fail. And yet, sometimes a DM will write an adventure when they are supposed to fail (get captured, let the bad guy get away, etc). However, there is a way for the players to fail without it feeling like a failure...and that is to give them a rousing success that includes the failure going off as a side effect.
As an example, my current Shadowrun campaign started with the player characters being hired to kidnap a mage and hold him for 24 hours. The run went perfectly and they all got paid. A rousing success! However...they soon found out that the victim was working as magical protection for the local mob boss who was killed during that 24 period...and that his heir was a woman who just happened to be dating one of the runners. The fallout is ongoing for that "success".
I could have used a heavy handed tactic to force the players into their predicament. After all, I needed the PCs to be in their current situation for the story and plot to advance. However, I "forced" them into it with a success, not a failure on their part. This concept can be used in almost any plot angle...
-The plot calls for the princess to die so a war can start between two nations. Instead of having the PCs fail to save the princess before she is killed, the PCs can rescue her but in the process they discover she has been a doppelganger working for the enemy nation for years. The PCs still succeed but the "failure" of their discovery starts a war nevertheless.
-The PCs attack an orc stronghold in a mountain pass that has been plaguing a region....only to discover that with the orcs dead the pass is now open to an invading army of barbarians. Instead of having the PCs fail to keep the mountain pass closed to the barbarians, they succeed by killing the orcs...with the end result being what the DM wanted - an invasion campaign.
It's okay to sometimes force something to happen to keep a plotline going, but it doesn't have to require the player characters failing at something to accomplish it.