The actual history of tipping: https://en.wikipedia.org/wiki/Tipping#History
And a bit on Sales Taxes: https://en.wikipedia.org/wiki/Sales_tax#In_the_United_States
From old family stories, I figure the real reason for tipping service workers is that both employers and customers want there to be plenty of service workers available - but the demand for their labor (restaurant customers, whatever) is very unpredictable compared to factory, farm, or gov't work. And service industries can't afford to keep a lot of idle workers around at full pay. So tipping is a simple revenue-sharing scheme, wrapped in social niceties, that boosts/cuts the service workers' income based on whether business is currently fast or slow.