What is and isn't legal immigration is always a moving target. A majority of US history included open borders where it was legal for anyone to get off a boat, provide some basic info, and go on to try and make their way here.
The idea of closed borders, immigration caps, etc is relatively modern and driven more by the fact that social entitlement programs cost money than a fear of dangerous people coming here.