There were no federal immigration laws until 1882 and the US did not have closed borders until 1924: "The primary justifications for early immigration laws were xenophobia, eugenics, and overt racism."
https://www.theguardian.com/commentisfree/2025/jun/17/us-immigration-system-profit
America had open borders until 1924. Racism and corporate greed changed that

The primary justifications for early immigration laws were xenophobia, eugenics, and overt racism. Understanding the history of immigration is essential

The Guardian
I unboosted this specifically so I could boost it a second time.
The drafters wanted easier access to cheaper Mexican labor, but they understood that if Mexicans had the same rights as companies to cross borders in search of better opportunities, then the “invisible hand” of supply and demand might make this labor less cheap. Accordingly, immigration restrictions helped to rig the game. In line with these interests, the Clinton administration, in power when the agreement took effect in 1994, not only went along with the plan to leave immigrants out of the deal, but also doubled down on closed borders with harsh new measures to restrict immigration through the Illegal Immigration Reform and Immigrant Responsibility Act (IIRIRA) of 1996.