A pipe dream is something typically regarded as an unrealistic hope or fantasy. The phrase can be traced back to the dreams experienced by opium smokers, which were very prevalent in the 18th and 19th centuries by the highly literate.
The earliest reference comes from The Chicago Daily Tribune in December 1890, where it is said “[aerial navigation] has been regarded as a pipe dream for a good many years.”
In 1895, the first reference to opium smoking with the phrase is found in The Fort Wayne Gazette. Detailing a story of a man who predicted the suicide of another man, the reference says that if “reputable men had not verified it” it would sound more like “the 'pipe dream' of an opium devotee.”