One, the question is not is it illegal, but is it right and fair.
Two, the American public does not support the Ban.
It satisfies his supporters that he "kept" a promise, and it's something that doesn't really give him additional political baggage. Whatever we are doing to keep people like the 9-11 terrorists from coming here appears to be working in that most terror attacks have come from citizens who were radicalized. There have been some attacks or planned attacks from individuals allowed to go to school or work here, though.
And it got the "fake" news to look at a different shiny object and took the light off his "big border tax" that even the gop was not pleased with.