Habeas corpus is a legal principle that protects individuals from unlawful detention, ensuring that anyone who is arrested has the right to appear before a court to determine the legality of their imprisonment. This principle serves as a critical safeguard against arbitrary detention, reinforcing the rule of law and the rights of individuals in times of both peace and crisis.