Jimmy Valentine shows far greater courage than Ben Price at the end of the story. Jimmy is almost certain to lose everything by opening that bank vault to release the little girl trapped inside. He will lose his fiancee Annabel, he will lose his business and his reputation as a respectable businessman, and he will go to prison--not for releasing the little girl, but because the safecracking tools he used to open the bank vault will be used as proof that he was responsible for the three felonies he committed after his release from prison. O. Henry describes those three jobs in some detail.
A week after the release of Valentine, 9762, there was a neat job of safe-burglary done in Richmond, Indiana, with no clue to the author. A scant eight hundred dollars was all that was secured. Two weeks after that a patented, improved, burglar-proof safe in Logansport was opened like a cheese to the tune of fifteen hundred dollars, currency; securities and silver untouched. That began to interest the rogue-catchers. Then an old-fashioned bank-safe in Jefferson City became active and threw out of its crater an eruption of bank-notes amounting to five thousand dollars. The losses were now high enough to bring the matter up into Ben Price's class of work. By comparing notes, a remarkable similarity in the methods of the burglaries was noticed.
Ben Price, on the other hand, is not taking any risks by letting Jimmy Valentine go free and pretending to believe Jimmy is a respectable businessman named Ralph Spencer. Ben Price is not a law-enforcement official. He is a private detective who specializes in protecting businesses, especially banks, which were not protected by the federal government in O. Henry's time. Ben seems to be a lone wolf, not unlike Sherlock Holmes, and can do pretty much as he pleases. Sherlock Holmes himself occasionally allowed criminals to go free if he felt they were not likely to commit further crimes. A good example of this is to be found in "The Adventure of the Blue Carbuncle."
So it is Jimmy Valentine who is taking the greatest risk. No doubt Ben Price's compassion is partially aroused by the fact that he understood the risk Jimmy was taking. In fact, it was much more than a risk; it was a sacrifice because Jimmy had no way of knowing there was any chance that Ben Price would let him go.