Habeas Corpus

What is a writ of habeas corpus, and how to petition a court for habeas corpus relief.