A writ of habeas corpus is filed to bring a prisoner before the court for any of the following reasons: to determine the legality of their imprisonment; to allow them to argue there is not sufficient cause to imprison them; to give testimony, or to be prosecuted.
Merriam-Webster Online Dictionary
habeas corpus (noun)1.
any of several common-law writs issued to bring a party before a court or judge , especially - habeas corpus ad subjiciendum
2.
the right of a citizen to obtain a writ of habeas corpus as a protection against illegal imprisonment