O. Henry is a master of irony, and this story is no different. Poor Soapy. He does everything in his power to get back "on the island" because he thinks this is the only thing he can do, being an ex-criminal and all. At least he had a warm place to sleep and three meals a day. He tries many times to get arrested, but the "cops" never really cooperate with him. Finally, at the climax of the story, he is outside of a church and he hears an "anthem" - or a church song -- a hymn, most likely. It moves him and he decides to turn his life around. Just then, a "cop" accosts him and tells him he is under arrest and is going to be sent to "the island". So he is arrested for doing nothing, and it is all because of the "anthem".
The "anthem" then is what gets him arrested. It has the opposite effect of what Soapy had intended. To him, it was an ephiphany that made him see the error of his ways and make a decision to reform. The "cop" was supposed to be his means to getting back on "the island" and not "the anthem" but in supreme O. Henry ironic style, it is "the anthem" that gets him in trouble.