The problem here is that the order was a hastily and poorly written executive order of the president.  It probably contradicts various human rights laws.  If Trump had waited for a properly crafted law to be passed by Congress then he would probably have a legal ban on immigrants, as abhorrent as that is.