Habeas corpus refers to the legal precedent which holds that a prisoner may not be held in custody without just cause. A writ of habeas corpus is a request, delivered to the custodian of an arrested person (police, sheriff, prison official). The writ requires the custodian to bring the accused person into court along with whatever proof the custodian is using to justify continuing the detention.
Sir William Blackstone, best known for creating a history of the development of the English legal system, described the early use of the writ of habeas corpus as resulting from the assumption that
The King is at all times entitled to have an account, why the liberty of any of his subjects is restrained, wherever that restraint may be inflicted.
Article One, Section Nine, Clause Two of the United States Constitution upholds the practice of using the writ of habeas corpus "unless when in cases of rebellion or invasion the public safety may require it."