Created in 2866, The Holodeck is a device initially invented for the purpose of enacting 3-dimensional porn, much like any previous technology worth mentioning. After its introduction, its existence was made known to Rick Berman and the writing crew of Star Trek: The Next Generation through the use of Che Guevara's time machine. Upon their discovery, they quickly made an effort to incorporate the device into every episode, often sodomizing small children and circus animals in the process.
It was frequently used as a substitute for the traditional self-exploratory method of doing something wildly out of character, then waking up to find that the entire thing (including consequences of ones' action) was a dream. This had two major impacts on life: first, it allowed a plethora of technobabble to be easily worked into the conversation. Second, through the use of semi-sentient computer driven micro-force fields, reverse wave-induced harmonics, and only slightly modified replicator technology, the need for morning-after laundering of sheets was almost entirely eliminated.
Some question the necessity of a magical box to re-enact old-west dramas when you're blasting through space finding new races and worlds, but apparently that gets boring after a while.
This is only part of a larger picture, of course. The entire scene was part of the United States Government's plan to develop an inexhaustible power source. Through the adaptation of Jean Baudrillard's ideas into poorly-executed science fiction, US scientists could harness the electricity generated from Baudrillard spinning in his grave; speeds in excess of 143 revolutions per minute were realized, generating an astonishing 1.21 Gigawatts of power.
This project encountered a major roadblock in 2001, when Star Trek: Voyager's series finale aired, and again in 2024, when Star Trek was declared illegal by the Federal World Government, along with Natalie Portman and Linux.
Despite it's original purpose, however, only Vulcans are able to use it for porn with everybody, including the captain, knowing about it, and not giving a damn.
Vulcans are also the only species known to complain when the Holodeck version of their wife is hotter than the real thing.
From time to time holodecks malfunction, this can attributed to the fact that they use Windows Vista. An apple based holodeck was released but was shelved due to it being based on the Macbook Air. at only 0.76 inches in thickness the average human was not able to use it, much like the Macbook Air