The Enterprise encounters an asteroid that actually turns out to be a huge alien bio-dome-like spaceship—carrying passengers who think they're living on an actual world. This spaceship, navigation having malfunctioned, is on a collision course with another populated world.
Meanwhile, McCoy learns that he has a terminal illness that leaves him with a maximum of one year to live. Upon beaming to the spaceship to investigate, Kirk, Spock, and Bones find that the inhabitants are at the mercy of an apparently computerized oracle that dictates thought and speech—speak the forbidden words and it kills you. Bones is elected to keep Natira (Kate Woodville), the landing party's host who finds herself enamored with McCoy, busy while Kirk and Spock try to figure out how to gain navigational control of the planet-ship.
The "spaceship planet" idea and some of the social implications are genuinely intriguing. There's an implicit analysis of a society built on censored thought, but the story doesn't dig as deep as it could've. Also unfortunate is that Bones' romance with Natira—a key emotional focus point in the story and a good idea—is a major letdown, severely lacking punch and devoid of passion or sweetness, thereby reduced to a plot element. It's a real shame, because I like Bones and would've liked to see this side of him more believably brought to the surface.