Besides being outlawed under international law, torture contributes nothing to rehabilitation efforts (attempting to make prisoners less liable to commit crimes is arguably the entire purpose of the correctional system, to correct) and is widely viewed as unethical.
Using it in rare cases where the crime is both heinous and the suspect is clearly guilty, it can be just. After all imprisoning or executing wrongly convicted people is also unjust.
Any form of punishment for innocents is unjust, but even criminals have human rights, and there is no scenario in which the state has the right to violate those rights.
Freedom from detention is a human right. Freedom of speech is a human right. Freedom of movement is a human right. And yet we limit and deprive criminals of those rights because they forfeited them when they committed the crime.
our justice system has imperfections that allow for innocent people to be subject to punishment, and torture of an innocent person is an injustice in itself
In some clear-cut cases, egregious wrongdoing deserves comparable punishment. Also harsher punishments deter crime (both reasons are why we punish rape worse than shoplifting).