while the individual man is an insoluble puzzle, in
the aggregate he becomes a mathematical certainty. You can, for
example, never foretell what any one man will do, but you can say
with precision what an average number will be up to. Individuals
vary, but percentages remain constant. So says the statistician.

He could be talking about the Law of Large Numbers or perhaps the Central Limit Theorem or, even more simply, any random variable with its individual values and its given probability distribution of the aggregate of its values.

In the book, Arthur Conan Doyle has Holmes reference the 19th century British philosopher, explorer Winwood Reade who wrote in his book The Martyrdom of Man:

All the events which occur upon the earth result from law: even those actions which are entirely dependent on the caprices of the memory or the impulse of the passions are shown by statistics to be, when taken in the gross entirely independent of the human will. As a single atom man is an enigma: as a whole he is a mathematical problem. As an individual he is a free agent, as a species the offspring of necessity.