The Holodeck is an instrument and a device used by scriptwriters too lazy to come up with fresh story ideas. Initially intended to replace the tiresome "Hodgkin's Law" plot, as well as the increasingly threadbare "time travel" trope, the use of the holodeck reached its nadir with ENT: "These Are the Voyages...", the episode that officially marked the end of Star Trek as a viable commercial franchise.
Holodeck malfunctions plagued every Starfleet vessel in recorded galactic history. The most destructive such malfunction occurred on the Enterprise-D, when the ship's holodeck jizzmopper Stinky McGillicudy accidentally scrubbed the floor of the holodeck with a more abrasive cleanser than usual, freeing Professor Moriarty, Darth Vader and Snidely Whiplash from their confinement and allowing them to tie Deanna Troi to holographic railroad tracks. Only the speedy intervention of Doubting Thomas (aka "The Tank Engine") saved the nubile young counselor. (TNG: "Bottled Ship".)