I've heard that some time in the past, it was routine for thousands of people to arrive at places like Ellis Island in New York, and then they were allowed to immigrate right then and there.
Nowadays, you usually need to apply for a Green Card, and it's done by lottery, and there is a very limited number compared to the number of people who want to move to the US. And now, to even visit, you need a passport (and probably a return ticket, and proof you're not going to illegally immigrate).
When and how did the shift happen to tightly-controlled immigration policies?
It wasn't just one single law but rather a series of laws. The first was the Page Act of 1875 that primarily targeted Asians, particularly Chinese people, that were immigrating to the western United States to work menial jobs like railroads. Just like we see in the debates today about Hispanic people coming to the United States to work mostly low-wage jobs, there were concerns about taking jobs away from white Americans, as well as diseases, immorality, and integration of the Chinese into American culture.
Another major law was the Immigration Act of 1924, which severely limited the number of people that could come from any one country to 2% of the number of people from that country that had already immigrated. This was similar to the Page Act in that it was designed to preserve a certain ethnic makeup of the country. But these laws continue to change over time and even now we see debates about how to "fix" them. The shift from almost entirely open borders to what we have now was very slow and incremental.
One of the early laws was the Page Act of 1875 (PDF). It imposed restrictions on Asian immigration to the US,, and further stated that:
[I]t shall be unlawful for aliens of the following classes to immigrate into the United States, namely, persons who are undergoing a sentence for conviction in their own country of felonious crimes other than political or growing out of or the result of such political offenses, or whose sentence has been remitted on condition of their emigration, and women "imported for the purposes of prostitution." Every vessel arriving in the United States may be inspected under the direction of the collector at the port at which it arrives, if he shall have reason to believe that any such obnoxious persons are on board