Prior to 1875's Page Act and 1882's Chinese Exclusion Act, there were no national immigration laws. None. There were laws related to naturalization and citizenship, to how vessels reported their passengers, to banning the slave trade. Once New York's Castle Garden Immigration Station opened in 1855, arrivals there reported names and origins before entering the U.S. But for all pre-1875 immigrants, no laws applied to their arrival. They weren't legal or illegal; they were just immigrants.

Moreover, those two laws and their extensions affected only very specific immigrant communities: suspected prostitutes and criminals (the Page Act); Chinese arrivals (the Exclusion Act); immigrants from a few other Asian nations (the extensions). So if your ancestors came before the 1920s and weren't prostitutes, criminals, or from one of those Asian nations, they remained unaffected by any laws, and so were still neither legal nor illegal. This might seem like a semantic distinction, but it's much more; the phrase "My ancestors came here legally" implies that they "chose to follow the law," yet none of these unaffected immigrants had to make any such choice, nor had any laws to follow.