Habeas corpus protects and individual from?

Habeas corpus protects an individual from unlawful detention or imprisonment by requiring the authorities to bring the person before a court and provide a legal reason for their confinement. It ensures that individuals have the right to challenge the lawfulness of their detention and prevents arbitrary arrests.