Habeas corpus, translated literally, means, "have the body." It is a function of law where someone in the justice system appeals to a higher court for relief of some form of procedural injury. Appeals courts are reluctant to grant writs of habeas because they could/would be abused by every guilty party that has nothing to lose just to gum-up the courts.
On a Constitutional level habeas can only be suspended by Congress. Abraham Lincoln violated the Constitution by suspending HC on his own but he was retroactively indemnified. Don't go looking for Lincoln-Trump comparisons in the media, though.
To address Horse's Ass With No Brains, in normal times rights to a habeas petition would require subject matter and personal jurisdiction of the court, i.e. is this particular court competent - you wouldn't go to a civil claims court for a national security issue - and is the petitioner someone over whom the court has power. In other words, as a practical matter, could a court Marshall be sent to retrieve the petitioner without stepping on someone else's turf?