Habeas corpus is a legal principle that protects individuals from being unlawfully detained or imprisoned. It allows a person to challenge the legality of their detention or imprisonment in court, and requires the government to provide justification for holding them in custody. The term "habeas corpus" is Latin for "you shall have the body," referring to the right of a person to have their physical body brought before a court.