For example, early immigration laws prevented Asians and Africans from entering the USA legally (except as chattel in the latter case). For most Europeans, however, immigration was relatively free and unrestricted until the 1800s and the onset of the Industrial Revolution. The first laws restricted immigration by those who were not of Western European descent; later, as more Eastern European immigrants arrived and assimilated into American culture, laws restricting their numbers permitted to immigrate were eased. Historically, as various waves of immigrants settled in the United States and assimilated, rules regarding their cultural groups' entrance into the USA were eased.
Today, immigration is theoretically open to all persons not guilty of felonies or other serious crimes. In actuality, a geopolitically-based quota system governs how many persons from each part of the world are permitted to settle permanently, with a lottery open to all comers for unused quota slots. (There are also additional complications to the system not discussed here.)
One consequence of laws restricting the number and ethnicity of persons entering the USA is a phenomenon referred to as illegal immigration, in which persons enter a country and obtain work without legal sanction. In some cases, this is accomplished by entering the country legally with a visa, and then simply choosing not to leave upon expiration of the visa. In other cases - most notoriously Mexicans in the USA without legal sanction - people enter the country surreptitiously without ever obtaining a visa. Often, people entering in this fashion are economic refugees - a class of refugee not recognized by the U.S. Citizenship and Immigration_Services (formerly the Immigration and Naturalization Service); these persons have left their home country in a desperate bid to provide financial support for themselves and/or their families. This is particularly true in cases where "minimum wage" in the US is several times what the average laborer earns in a given country; such immigrants often send large portions of their income to their countries and families of origin.
Much of the contraversy today with immigration to the US involves anti-illegal immigration idealogies. Critics of these ideologies say that those who call to and end for "illegal immigration" really are calling for an end to all immigration, but are not realizing it. This is for two reasons, one being that all the problems associated illegal immigration (race to the bottom in wages, etc.) also apply almost equally to non illegal immigrants. Secondly, critics believe that anti immigrant idealogues misunderstand the immigration process and do not realize how many workers who they seem to be replacing jobs that American citizens can do are here completely legally, albeit without citizenship (this number is larger then the amount of illegal immigrants from per country).
In the dawn of the 21st century, the contraversy was revived because many high tech and software engineering workers were being brought from India on H1 visas. Critics claimed that these people were working for less money and displacing American citzens. The companies who imported the workers argued usually that there were not enough American citzens to fit the job. A few economists argued that wether or not that might be true, it was better to import the workers, otherwise the companies would simply offshore the entire operation to India itself. This would likely be worse for the US economy as a whole, because in the first scenario Indian workers here in the US would at least be spending money in the United States, while the supranational corperation that would export the workers to India would probably not pass down as much of the savings to the US consumer who purchased for them.
Immigration, including illegal immigration, is largely driven by economic considerations. It is also a by-product of globalization.
In contrast to economic refugees, who are not generally granted legal admission, other classes of refugees can and do enter the United States (in a manner that technically is) illegally, but are then granted legal status through a process of seeking and receiving asylum. For the most part, such persons are fleeing warfare; escaping persecution based on political or religious beliefs; or are victims of torture in their countries of origin. Some asylum cases have been also granted based on sexual orientation or gender, where cultural norms of the home country create and sustain conditions that make life unsafe or unbearable for the individual.