First, welcome to CFC!!!!
Second, it sounds to me that you are very new to the game.
The fact is that Slavery is one of, if not THE,, most powerful mechanics in the game. So hearing you did not adopt Slavery until a city had 20 unhappy citizens is beyond mind-boggling.
So here's a rundown:
1) Each unhappy citizen costs maintenance. You are paying for them to literally do nothing.
2) Each citizen is worth 30 hammers (normal speed) when whipped, which can be used to finish buildings or units
3) The hammers from a whipped citizen(s) are applied to the current build in the production queue to complete that item
4) If the total hammers from whipped citizens exceed the total production cost of an item - any accumulated hammers into said item, those hammers are turned into Overflow (OF) which can be used in a subsequent build (this is very powerful). It basically allows you to turn food into hammers.
5) There's a penalty to hammers when you whip an item on the first turn of the build
6) Wonders receive a whipping penalty in general, so it is not advisable to whip wonders usually except if you just need to make sure you get it in time.
7) The reason why Versailles needs 11 citizens is that it needs approx. 330 hammers to complete the wonder (11x30)
So you very much want to run Slavery almost as soon as you get BW, and you generally don't want your cities to be unhappy, although it is fine to let a city grow a bit unhappy temporarily so that you can whip those unhappy citizens. Unhappy citizens are free production when whipped, but otherwise do nothing for you but cost you.
Ofc, you also want to find ways to get more happiness as well such as Hereditary Rule civic and resources. DO NOT let your cities grow to 20 unhappy citizens much less 1 or even 2. Either whip off those citizen asap or use methods to curb growth such as adjusting tiles or running specialists..
Lastly, I assuming you have a lot to learn about the game. I recommend reading up and spending more time over on the Strategy & Tips forum.