It's an interesting question, and to me a real ethical gray area. At my favorite bar, I usually tip very generously, and all the bartenders know me. I tend to get my first drink free, and if I stay for a while, often a shot with the bartender later. For those, I tip extra big - not quite, but almost, the cost of the drink. For a while I felt bad about "taking advantage" of the system. But in fact I think this is part of the system, because every bar needs regulars, and since people like me and I don't cause trouble, my patronage is useful even to the owners (though they may get less revenue from my drinks). I also think this may constitute a sort of perk for the bartenders - to be able to give free drinks to a limited number of friends probably makes them enjoy their job more. I do notice that after I get a free one the bartender makes some sort of note on a piece of paper near the register, so maybe this is an official part of the system.
I'm not sure if the restaurant business is the same, but I can imagine that the owners anticipate this sort of thing, and maybe even encourage it, since it means their employees get more money and might be happier as a result.
But yeah, it doesn't seem particularly fair, at least the way I was raised to think of it.