The historical period that you mention in your question witnessed a dramatic development in industrilization and mechanization in the United States. These processes led to the specialization of workers for particular tasks and their concentration in large factories. African Americans and immigrants were important part of this workforce. Yet, a revealing fact of their social status and the rights they could lay claim on is that they were excluded by the majority of the labor unions of the time, except for the Knights of Labor and the IWW. Racial prejudices were also reinforced as Big Business used African Americans and immigrants as strikebreakers. Discriminated on the workplace to start with, African Americans and immigrants were also discriminated by labor unions which looked at them with suspicion.
Job opportunity was the main attraction that the U.S. exercised on immigrants who made the most significant contribution to the impressive growth of American cities between 1870 and 1920. The massive inflow of immigrants, particularly from Southern and Eastern Europe, caused concerns in many Americans, even in future institutional leaders such as Woodrow Wilson who wrote in 1902 that immigrants came out of
the ranks where there was neither skill nor energy, nor any initiative or quick intelligence.
The fact that most of these immigrants came from Catholic or Jewish religious backgrounds only increased Protestant fears.
In the case of African Americans, in addition to the quest for a better job, fleeing racial violence was instrumental in their mass migration from the rural South to the industrialized northern cities. Unlike European immigrants, however, African Americans tended to find jobs not in the industrial sector but in the service one.
The idea that the U.S. was the land of opportunity did not mean that immigrants automatically found a job or that they could personally experience a "rags-to-riches" story. Poverty was still widespread and particularly the groups of your question often lived in precarious conditions. This stimulated an important debate in American society between Reformers who sought to introduce state relief measures to help these people out of poverty and the so-called Social Darwinists who thought that anyone who strongly believed in his own means and worked hard could get out of poverty. Reformers demanded more rights for immigrants and urged the government to play a more significant role in promoting their rights to safe workplaces, better salaries and shorter working hours as well as improved housing conditions.