Star Trek S3E21: The Cloud Minders
Yeah, this one was... not so great. There was something about a class divide here, with one group of people (Troglytes) doing all the physical labour in the mines while another group (Stratosians) is living in cloud cities in luxury.
And the Troglytes are unhappy and rebelling and then... I guess it turns out there's gas in the mines that make them stupid and violent, and the solution is to give them masks so that the gas doesn't affect them. yeah, I don't know.
And then we randomly have Spock talking about Vulcan reproduction (which, in an earlier episode, was described as something so deeply personal that he only told Kirk after receiving a promise of complete confidentiality) with some woman he'd met maybe an hour earlier.
From what I've read the original story by David Gerrold was much different and somehow it got butchered pretty badly to where Gerrold was not happy by how it came out.