Moriarty was only actually in two Doyle-penned stories, The Final Problem and The Valley of Fear, but was mentioned in others

Sherlock Holmes author Arthur Conan Doyle created Moriarty for one reason: to kill off Sherlock and move on to other works

Professor James Moriarty is the archenemy of the world's greatest detective, Sherlock Holmes. This "Napoleon of Crime" was basically literature's first super villain, a dark mirror image of our hero and every bit the genius Holmes was. A mathematics professor who provided protection to England's criminals in exchange for obedience and tribute, the remorseless Moriarty orchestrated massive crimes without directly participating in them, thus allowing him to remain above suspicion. Moriarty and Holmes ultimately both (apparently) died fighting each other at Reichenbach Falls.