There are reports that the Trump administration asked for data to back up the immigration ban, and the intelligence agency's report said there isn't a threat from the selected countries.
In fact, former intelligence officers are saying the travel ban hampers our our ability to gather intelligence and stop attacks before they occur. The ban is harming our relationships with other governments and existing spy networks.
You can't really say the ban keeps bad guys out of America where the existing process has often been identifying them even before they apply for a visa at an embassy.