After the Constitution was amended in the wake of the Civil War, slavery was ended as an institution but those who were freed from bondage were still limited in their choices. Many who did not end up sharecropping worked in menial positions, such as servants, waiters, barbers and railroad porters. These were pretty much the only occupations available to them. For restaurant workers and railroad porters, there was a catch: many employers would not actually pay these workers, under the condition that guests would offer a small tip instead.
It started much earlier than that and has roots in racism. https://time.com/5404475/history-tipping-american-restaurants-civil-war/
TIL, thanks!