It's supposed to be. But, some workers aren't paid the same hourly rate as others, and tips being given is the surface level reason given for that. It's more classist amd racist in real terms.
So, since a wide swath of workers only get paid an insulting, horrible hourly wage, tips are how they actually pay their bills. So it's become mandatory in any real sense. It isn't required by law, but you're fucking over people when you don't, so there's still an obligation.