Ryan Avent gives it a shot:
One thing that I wish Democratic candidates would or could emphasize is that a more liberal immigration regime isn’t just compatible with better security, it may actually facilitate it. If you allow economic immigrants ready access to the country, then they have no reason not to come in through the front door, at which point they can get fingerprinted, get their visas and identification cards, be placed in the government’s databases, checked against terrorist profiles, etc. This way, we know who is coming into the country, and we know that anyone not using the front door is probably not a legitimate economic immigrant.
I'm convinced. I'm not, however, convinced that people's concern about immigration is really driven primarily by national security worries as opposed to cultural anxieties.