Can someone give me some basic tips on how to use slavery? I think one of the main reasons I suck so badly at this game is because I either don't use it or I use it incorrectly.
The really basics (see the detailed guide posted by Gumbolt above, for more advanced tips):
(1) Slavery sacrifices population for 30 hammers by population, as many as needed to at least complete the item, producing overflow production if necessary (e.g. if you have 40 hammers left on the item, it will produce 60 at the cost of 2 population, and your city gets 20 overflow production. BUT it cannot use more than half the population (the option will not be offered if you don't have enough population to complete the item).
(2) You shouldn't generally use slavery before you have put at least some hammers into the item, otherwise you get a big penalty (only 20 hammers by population). You also shouldn't use slavery on wonders due to similar penalty (but the overflow from completing another build with slavery can go into the wonder).
(3) You should try to use slavery when it uses at least 2+ population (so there are over 30 hammers left to complete the item). The reason is that in addition to losing the population, you get 10 turns of unhappiness when using it, and there is not more unhappiness from using more population. Because each point of population adds 1 unhappy face from crowding, as long as you use more than 1 population, the city will be less unhappy after using slavery than before.
(4) If you use slavery again before the 10 turns is up, you get another 10 turns added, and another unhappy face (that 2nd unhappy face disappears once the counter is down to 10 turns again). It's not wrong to have multiple unhappy faces this way if you need the production and your cities can handle the unhappiness. It's very common to do so when you switch from gaining techs mode (where you want all your cottages worked) to war mode (when you want to produce units quickly and will take a temporary hit to your economy to do so).
(5) The granary makes slavery a better food-to-hammer conversion because cities grow back up almost twice as fast. Therefore the granary is usually a priority to build in your cities if you plan to use slavery, at least past the initial phase of the game when building new settlers / workers to claim your land is more important than buildings.
(6) Because of how efficient the food-to-hammer conversion is, It's always good to settle cities that have plenty of food. If you have plenty of food and your city grows so much the citizens are unhappy and/or are working weak (unimproved) tiles, it's a good time to use slavery.
(7) The flipside of that is that you are using slavery too much if you don't have enough population to work the good tiles in your city and/or you have too many unhappy citizens to work the good tiles.
(8) Recommended mod: play with the BUG/BULL mod (or BUFFY, which includes BUG/BULL) so you can see more information on how many populations are needed to rush the item and how much overflow production you get, right in the city screen's production bar.