Darkness is important to this story because it hinges on the fact that "Silky Bob," who is waiting in the darkened doorway of a hardware store for his old friend Jimmy Wells, does not realize that the man who comes to meet him at their appointed rendevous after the passage of twenty years is not Jimmy Wells. He strolls up the street arm in arm with the man he takes to be his old friend, slightly changed by the years.
At the corner stood a drug store, brilliant with electric lights. When they came into this glare each of them turned simultaneously to gaze upon the other's face.
Because of the change from darkness to brilliant lights, "Silky Bob" realizes that the man he is with cannot possibly be his old friend. He finds out that his companion is a plain clothes detective and that he is under arrest. The reader realizes that "Silky Bob" has been prospering in the West, as he boasts to the patrolman, but he has been doing so by committing crimes and is wanted by the police in Chicago and perhaps elsewhere.
It was also because of the darkness that Bob did not realize that the patrolman he had been talking to earlier was actually Jimmy Wells, his old friend, who had become a policeman. The plain clothes detective hands "Silky Bob" a note explaining everything to him as well as to the reader.
"Bob: I was at the appointed place on time. When you struck a match to light your cigar I saw it was the face of the man wanted in Chicago. Somehow I couldn't do it myself, so I went around and got a plain clothes man to do the job. JIMMY."
O. Henry's thesis is that a lot can change in twenty years, that nothing remains the same. The restaurant where the friends had promised to meet had been torn down five years earlier. Bob had been leading a life of crime while in the meantime his friend had become a policeman. But he had kept his promise to meet his old friend at the place where 'Big Joe' Brady's restaurant had once stood.
O. Henry had a genius for depicting settings. He captures the lonely, somewhat sinister feeling of a big-city street at night. He uses contrast effectively, starting off with the setting in darkness and then ending in the brilliant lights on a street corner.
"After Twenty Years" closes with one of O. Henry's characteristic surprise endings. His surprise endings usually have an ironic twist. The irony in this particular story involves the fact that the friend had turned into the protagonist's nemisis. Jimmy the cop still felt some friendship for Bob but not enough to ignore his duty to enforce the law. Friendships do change with time. It is a sad fact of life--and O. Henry's stories are full of examples of the sad facts of life. He made poetry out of that sadness in many of his best stories.