If no legal cause for the imprisonment or restraint is shown the person shall be immediately discharged therefrom.