The music that Soapy hears at the church would not have had such a strong effect on him had it not been for the fact that he had been trying so hard to get himself arrested and sent to jail for the winter months. He is feeling depressed, dejected, defeated. And he still has the spectre of a cold New York winter haunting him. He could easily freeze to death or catch terminal pneumonia if he had to spend the winter outdoors. It is the combination of Soapy's feeling that some supernatural force has been preventing him from getting arrested, in spite of some of his outrageous actions, with the beautiful anthem being played by the church organist that brings about what might be called an epiphany in Soapy's soul.
The conjunction of Soapy's receptive state of mind and the influences about the old church wrought a sudden and wonderful change in his soul. He viewed with swift horror the pit into which he had tumbled, the degraded days, unworthy desires, dead hopes, wrecked faculties and base motives that made up his existence.
O. Henry's story was published in 1905, over a hundred years ago. Laws against such misdemeanors as vagrancy, loitering, public intoxication, and panhandling were much more strictly enforced. Since there were so many such offenders in a city like New York, the police typically left them alone as long as they stayed in a certain area, which in every big American city was usually called Skid Row. Soapy has evidently strayed too far over the line. The fact that he is hanging around a church makes him look suspicious to the cop, who asks,
"What are you doin' here?"
"Nothin'," said Soapy.
"Then come along," said the policeman.
By Soapy's own admission, from the cop's perspective, he is guilty of both vagrancy and loitering. So Soapy gets his original wish. He is sentenced to three months on Blackwell's Island.
Vagrancy was a very vague and flexible term in older times. The police could arrest practically anyone on what they called a "vag charge" if he didn't have a fixed address, or identification, or some money in his pocket, or if he was shabbily dressed or sleeping out in the open. Laws against vagrancy and loitering still exist but are not so strictly enforced, partly because the jails are overcrowded and partly because of the activities of civil liberties groups like the ACLU. The situation was entirely different in O. Henry's time. The police could not only arrest anybody, but they used extreme physical force with little provocation.
One of the best novels dealing with this subject is Theodore Dreiser's Sister Carrie, in which George Hurstwood descends the social ladder in New York City until he finally commits suicide in a flophouse room. A good book dealing with the horrible prison conditions of a hundred years ago is Jack London's little-known The Star Rover.