The fact that Jimmy and Bob were friends twenty years ago does not necessarily mean that they are still friends. The main theme of O. Henry's story is that people change. These two men have grown in different directions. It happens all the time. They should be described as erstwhile friends. Their relationship is based on the fact that they used to be friends. Jimmy would not want to be a friend of Bob anymore. Bob is a crook, and Jimmy has chosen to be an upholder of law and order. If Bob had remained in New York for these past twenty years, the two men would have lost their affection for each other.
Absence blots people out. We really have no absent friends.
The note that Jimmy leaves with the plainclothes detective to give to Bob should prove that Jimmy had only slight misgivings about having Bob arrested.
Bob: I was at the appointed place on time. When you struck the 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 plainclothesman to do the job.
O. Henry didn't want to have Jimmy arrest Bob because that would have required a big scene in which Bob appealed to their old friendship and Jimmy had to explain that he had a duty to perform. The truth is that the friendship ceased to exist the moment Bob lighted his cigar and Jimmy realized who his old friend had become over the past twenty years. Bob might have been shocked at that point, too, if he could have seen Jimmy face and his uniform; but he couldn't see Jimmy because he was blinded by the light of his own match. He only saw the vague figure of a uniformed police officer. If he could have seen Jimmy at that point, Bob might have realized that their old friendship had gone out just like his match. He couldn't be friends with a cop, and Jimmy couldn't be friends with a crook. People change over the years, and friendships burn out just because people change.
There is no question that Jimmy is justified in what he does to his friend. He should do it even if they were still good friends, but they are not really friends any longer. Bob was mistaken to think that he could spend twenty years leading a life of crime and then go back and expect Jimmy to have the same high regard for him as before. Jimmy was basically an honest, responsible man, and he wouldn't have liked Bob after twenty years even if he hadn't become a cop. O. Henry was making the contrast between the two men extreme by having Jimmy turn into a cop, but the relationship would have been over even if Jimmy had become an office worker or something else.
It is very unwise to make friends with dishonest people, or to maintain friendships with people who turn out to be dishonest. It is best to terminate such friendships completely, regardless of hurt feelings. Such "friends" only cause you trouble, just as they inevitably cause themselves trouble. Jimmy's note not not only explains how he recognized Bob and why he didn't arrest him himself, but by implication it is saying a final and irrevocable goodbye.