Moriarty, as played by Daniel Davis, first appeared in the episode “Elementary, Dear Data” (December 5, 1988). In that episode, Data (Brent Spiner) had become too good at solving Sherlock Holmes mysteries on the holodeck, making the deduction and investigation parts of the stories — the fun parts — unnecessary. Geordi (LeVar Burton), bored in his role as Dr. Watson, suggested to Data that he needed to be challenged by a mystery, and asked the holodeck to create a character that would actually be capable of besting Data. Note that Geordi said “Data” and not “Sherlock Holmes.” The holodeck, using heretofore unknown powers, created a Prof. Moriarty that is self-aware. Moriarty knows he is a citizen of 19th-century England but also finds himself able to access the Enterprise’s computers, slowly becoming aware that he is a mere character in a high-tech simulation. He will eventually try to gain control of the ship.
It will take a great deal of negotiation from Picard to convince him to stop his shenanigans. Moriarty is stored in the ship’s memory to be dealt with at a later time. He will be restored accidentally in the episode “Ship in a Bottle” (January 24, 1993) where he will announce he was aware of the passage of time, even when stored in a memory bank. Once again, he will attempt to take over the Enterprise. At the end of the episode, Moriarty is duped into a simulation, and he is placed into a computerized cube that will provide him and his beloved wife with a lifetime of adventures.