While torture doesn't work all of the time, it works most of the time. Here is part of the way it works, especially at places like Guantanamo.
Often you don't know if the person you are torturing knows anything or not. Maybe he doesn't know even the least bit about the things you are questioning him of. He is still useful for you. Here's how.
Your political masters - the people who are your bosses - want confessions along certain lines. They don't care if the confessions are the truth or not. They simply want the confessions in a certain way so that they can use them for political purposes - to propagandize the "free" people.
Over the decades, psychologists have figured out ways for you, the torturer, to ask questions of your torturees, to elicit the answer you want to hear from them, in the way you want to hear it. In other words, you want to ask them questions in such a way that makes it look like you are asking them legitimate questions. What you are really doing is feeding them the answers that you want them to "confess" to so that you get a confession that you can use as propaganda, whether or not the particular torturee has any knowledge of what is going on regarding the thing that you are questioning him about.
This is part of the reason why the Guantanamo prisoners have been kept for so long. They have been going through classes - torture classes - that have turned them into good subjects out of whom the torturers can get the confessions that they want to hear, to use for propaganda purposes. The training takes a long time. Some torturees die from it. But it has to look real. So, when you get a batch of torturees trained, you don't want to let them go unless you absolutely have to.
In the event you don't think this is true, just consider the police, especially in big cities. You have probably heard the term "good cop, bad cop." That's where two cops get on your case. The bad cop accuses you (to induce fear into you) while the good cop sticks up for you (to make it look like he is your buddy, helping you). What they are both doing is trying to elicit the confession that they want to hear out of you.
This cop thing is torture. It is a mild form of Guantanamo. If the laws weren't so strict with regard to using torture on U.S. citizens, the cops wouldn't have to resort to such complex tactics. They would simply go and beat it out of you... whatever they wanted to hear... truth or not. They often do this right now. I bet there are some forum contributors who have had this experience.
So, yes. Torture works. But very often it isn't being used for the purposes that the general public thinks. Rather, it is being used to propagandize and manipulate the public through false confessions that look real.