The person who is tortured, is usually tortured because he or she has some information the other people want. Torture has in the past also served as a punishment. In 1600 Anton Praetorius fought against torture and against the hunting of witches.
Almost all countries agree that torture is a violation of human rights. This has been stated in the Universal Declaration of Human Rights. It is more difficult for people to agree what things are torture and what things are okay to do to prisoners.
Torture is a crime in many countries and it was made against the law on December 10th, 1948.
A thought experiment on whether torture can ever be justified is the Ticking time bomb scenario: Suppose the government holds someone for questioning, and that the person is the only one who probably has some information regarding a time bomb. If the bomb explodes, this will cause many victims, and many people will probably die. Also suppose that the person does not want to reveal this information. The question is now, whether it is legitimate to use torture to get the information.