As the semester closes, a student came in to collect his final and we got to talking about immigration. He's concerned about illegal immigration, largely for security reasons. Keep out the illegal immigrants and you'll to keep out the terrorists. It only takes one to make a disaster, after all.
But the optimal amount of terrorism (or pollution, accidents, illiteracy) is not zero. It might seem so because we really don't like seeing bad things happen (terrorist attacks being some of the most tragic) but complete prevention is a very costly thing to do.
Reducing terrorism requires the command of a vast amount of resources. Thus increasing security reduces the amount of things we can do (workers are busy patrolling borders). This "opportunity cost" is can actually cost lives: doctors tend soldiers with heat stroke instead of citizens with heart attacks. Terrorism reduction through border control also reduces the number of people who peacefully work in the US (the vast majority of them) so our opportunity cost deepens. We not only have fewer people producing other things, we have fewer people producing at all.
The cost of terrorism reduction increases faster than it falls. Picking out the obvious amateur is pretty easy, but once all the easy guys are caught, tracking down the elusive expert is much harder. For each percentage point closer to zero we get, that single point costs more and more. Our "increasing marginal cost" puts a tremendous amount of strain on our economy without obvious benefit beyond that one more person captured.
Preventing terrorism in the U.S. is particularly expensive. The country's size makes it that much harder to find terrorists. Its decentralization means any terrorist attack will have a small impact on the functionality of the country. Its productivity means that we are giving up so much more when we wander the desert looking for illegals. The accounting costs are very high. The opportunity costs are very high. The benefits are pretty low. Zero is not the optimum.