This is a fascinating premise for a fictional story, but it's not part of the original canon created by Sir Arthur Conan Doyle.
In the original stories, Sherlock Holmes and Professor Moriarty are arch-nemeses, with Moriarty being a criminal mastermind who Holmes ultimately defeats.
It's possible that you're thinking of a fan fiction or a different work of literature that explores this concept. If you could provide more details about the book you're thinking of, I might be able to help you identify it.