Arthur Conan Doyle freely acknowledged that he had gotten his inspiration for the Sherlock Holmes mysteries from Edgar Allan Poe's tales of ratiocination about C. Auguste Dupin, particularly from "The Purloined Letter" and "The Murders in the Rue Morgue." Poe uses a narrator who describes what he observes the detective doing but without understanding why. Then the explanation of the protagonist's reasoning process is given by Dupin himself at the end of the tale. The narrator participates in this unraveling by asking questions that have perplexed the reader.
In "The Red-Headed League," after John Clay has been arrested and carried off to prison, Doyle has Watson quote Holmes as he explains his whole line of reasoning. Adhering to the plot formula invented by Poe, Doyle has the two friends alone in a comfortable room with all the time in the world for conversation. By putting the deductions at the end of the story, the author saves the most interesting part for last, because the reader wants to know how on earth the brilliant detective was able to comprehend what is still a dark mystery to both the reader and the narrator.
"You see, Watson," he explained in the early hours of the morning as we sat over a glass of whisky and soda in Baker Street, "it was perfectly obvious from the first that the only possible object of this rather fantastic business of the advertisement of the League, and the copying of the 'Encyclopeaedia,' must be to get this not over-bright pawnbroker out of the way for a number of hours every day."
Watson continues to ask pertinent questions, such as, "But how could you guess what his [John Clay's] motive was?" Most importantly, Watson asks: "And how could you tell that they would make their attempt to-night?"
The answer to the posted question, In "The Red-Headed League," how did Holmes guess when the crime would be attempted?,is contained in a single paragraph near the end of the story.
"Well, when they closed their League offices that was a sign that they cared no longer about Mr. Jabez Wilson's presence--in other words, that they had completed their tunnel. But it was essential that they should use it soon, as it might be discovered, or the bullion might be removed. Saturday would suit them better than any other day, as it would give them two days for their escape. For all these reasons I expected them to come to-night."
It would have been a big job for the two burglars to move all those heavy boxes of gold through the tunnel to the pawnshop, then to load all the boxes onto a wagon and make their getaway. Most likely, they would have waited until early Sunday morning before loading the wagon. Since John Clay was an employee of Jabez Wilson, he could have given some plausible explanation to a policeman if one had happened to come along while they were in the process of loading the loot.
The only thing that the ingenious John Clay did not foresee was that Jabez Wilson would experience such a strong reaction to losing his lucrative position at the Red-Headed League office that he would go to Sherlock Holmes for advice. Holmes and Dr. Watson often get drawn into sinister and complex cases which start off with someone calling on them about an apparently trivial problem. Holmes had to be characterized as a man whose hyperactive intellect made him easily bored and who would therefore be glad to take on practically any mystery regardless of its apparent triviality or the possibility of collecting an appropriate fee.