It has for its purpose to inquire into all manner of involuntary restraint or detention as distinguished from voluntary and to relieve a person therefrom if such restraint is found illegal. The writ is the proper remedy in each and every case of detention without legal cause or authority. Its principal purpose then is to set the individual at liberty.