Habeas corpus is prerogative writ of ancient origin directed to a person detaining another, commanding him to produce the body of the prisoner at a designated time and place, to do, submit to, and receive whatever the court shall decide. In re Hart, 178 Mont. 235, 240, 583 P.2d 411, 414 (1978).
The writ of habeas corpus is the remedy the law offers for the enforcement of the civil right of personal liberty. In re Hart, 178 Mont. 235, 239, 583 P.2d 411, 414 (1978).
From the time of the Magna Charta, the Great Writ of Habeas Corpus has been liberally employed as a means of guaranteeing that justice be accomplished and that a miscarriage of justice will be remedied. The writ acknowledges the principle that the rights of freedom of the individual are worthy of protection. Lott v. State, 2006 MT 279, ¶ 20, 334 Mont. 270, 150 P.3d 337 (citations omitted).
The purpose of the petition is to determine the legality or illegality of the restraint. In re Hart, 178 Mont. 235, 240, 583 P.2d 411, 414 (1978); Keating v. Sherlock, 278 Mont. 218, 924 P.2d 1297 (1996). It is a legal proceeding independent of the proceeding under which the detention is sought to be justified. Habeas corpus is available to inquire into the cause of imprisonment or restraint and, if illegal, to be delivered therefrom. In re Hart, 178 Mont 235, 240, 583 P. 2d 411, 414 (1978); § 46-22-101(1), MCA.