The US is a sovereign country and can allow or disallow entry to their country for any or simply no reason at all. They could decide that anyone wearing a red hat is cause for a travel ban, it's their right.

What I find most interesting is that the travel ban countries are also nations that receive the most "foreign military aid" from the United States, arms in other words. Maybe if the US State Department and the CIA would stop arming these countries to the teeth, they'd have fewer terrorist worries to deal with. In Iraq alone, billions of dollars a year are spent on arms, pure US Military aid.