The writ of habeas corpus is a legal remedy against unlawful detention. It ensures that a person in custody must be presented before a judge.
Its main purpose is to safeguard individuals from being held without justification.
It ensures liberty by preventing arbitrary or illegal detention by the state.