Deathtrap (plot device)

A deathtrap is a literary and dramatic plot device in which a villain who has captured the hero or another sympathetic character attempts to use an elaborate, improbable, and usually sadistic method of murdering them.
It is often used as a means to create dramatic tension in the story and to have the villain reveal important information to the hero, confident that the hero will shortly not be able to use it. It may also be a means to show the hero's resourcefulness in escaping, or the writer's ingenuity at devising a last-minute rescue or deus ex machina.
History.
This plot device is generally believed to have been popularized by movie serials and 19th-century theatrical melodramas. A well-known example is the cliché of the moustache-twirling villain leaving the heroine tied to railroad tracks. Its use in the James Bond film series and superhero stories is well known.
Narrative use.
It is a common criticism that it is unbelievable in story plots to have villains try to kill the heroes in such elaborate ways when they could use simple methods like shooting them. Throughout the decades, comic book writers have responded to these complaints by devising ways in which the deathtraps have served other purposes.
For instance, one "Legion of Super-Heroes" story by Jim Shooter had a team of Legionnaires put into a variety of deathtraps and the villains "wanted" the heroes to successfully escape. This was because the real purpose of the deathtraps was to have the Legionnaires use a great deal of energy doing so, which the villains then harnessed for their own benefit. Other stories have had villains use deathtraps as a means of testing the heroes or to distract them while the villain attends to other matters. On some occasions, the deathtrap is a machine that "absorbs" the energy from the hero/heroes.
Another rationalization for a deathtrap is when a particular villain simply enjoys leaving his victims some small chance of survival, just for the sake of sport. Such "sporting" villains include the Riddler, who has an uncontrollable compulsion to create intellectual challenges for his enemies. Also included in this list is the Jigsaw Killer, who places his victims in life-or-death situations to prove that they appreciate life. The Joker and Arcade are other villains who simply enjoy the challenge.
On occasion, the villain may employ a slow deathtrap because they enjoy their victim's suffering prior to death, either due to sadistic tendencies or a desire for painful vengeance.
In a similar vein, the villain, often a megalomaniac, may feel that, as a reflection of his own imagined greatness, it would be "beneath him" to murder his enemy like any common criminal, and that his enemy's death should be the worthy spectacle that a successful deathtrap would provide. In contrast, he may feel that his enemy, having provided him with a worthy challenge in their earlier encounters, himself "deserves" such a grandiose death, or that the enmity between the two is so "epic" that it merits no less than such a conclusion.
Conversely, the protagonists' act of falling into such a trap may itself be the reason they are written off and left unattended. The villain, disappointed in such a non-threatening opponent, loses interest, and intentionally leaves some chance of escape for the protagonists to "redeem" themselves. However, the disillusioned villain tends to assume that the chance is minuscule. Despite secretly hoping that the opponent survives and proves worthy of interest, the now-bored villain is invariably shocked when that actually occurs.
If fully serious, the villain may simply be too insane to recognize the impracticality of the situation, although this characterization is rarely seen outside of deliberately parodic characters such as Dr. Evil.
A more recent reason is villains do it simply because it is considered 'tradition' or 'rule' of being a supervillain to place a hero in a deathtrap and then leave them to their fate. This even goes as far as heroes, or other villains, insulting a villain for attempting to avoid using a deathtrap or staying to watch. El Sombrero is one villain who exemplifies this reason.
When a hero's sidekick or loved one is placed in a deathtrap, its purpose is often to distract the hero, occupying time and attention while the villain pursues their evil plan. Less frequently, the villain intends to instill grief and guilt as a means of defeating a hero that cannot be defeated physically. Multiple secondary characters may be placed in deathtraps to offer the hero an agonizing choice, ostensibly forcing the hero to save one victim and leave the other(s) to die.
Famous examples.
A simpler variation on the deathtrap is the villain speech, also known as "monologuing". The villain, after having captured the hero or another victim, gives a long speech taunting and sneering at his victim, pontificating on how said victim will soon die, and reminiscing over how he tried for so long to get his kill and is now about to reap the reward. Villains may also give away details of their evil plots, on the rationale that the victim will die immediately and the villain often believes their victim deserves to know. This speech, given when the villain could have just killed the victim in a matter of seconds, is invariably used to give another character time to come in and save the victim, or for the victim to escape. In "The Incredibles" (which used the term "monologuing"), Mr. Incredible and Frozone attacked villains in the middle of their speeches (Mr. Incredible is seen attacking Syndrome and Frozone is mentioned to have attacked Baron von Ruthless off-camera). In a literary sense, the villain speech is also used as a form of exposition.
Even in relatively realistic stories, villains will often take a moment to say something pithy before finishing off the victim. The antagonist would often leave the victim to die whilst they commit their evil scheme. This is echoed in the film "2001 - A Space Odyssey" when Hal the supercomputer, confident that Dave will soon perish outside the ship, tells him that he is about to take control of the expedition and then sees Dave off with the flat remark: "This conversation can have no meaningful purpose anymore - goodbye!". Dave manages to make his way inside and kill Hal.
Spoofs.
The concept of the deathtrap/monologue is featured in many satires.