Synopsis
The Enterprise is delivering medical supplies to Makus III, but they encounter a quasar. Kirk launches the shuttle Galileo to gather data. Unfortunately, the Galileo immediately loses control due to space stuff from the quasar and crash lands on a shit planet called Taurus II. Which leaves open the question of why they call it Earth rather than Sol III.
There's some stuffy Federation jerk pressing Kirk to abandon the crew of the Galileo, but Kirk insists on searching.
The main cast members on the Galileo are Spock, McCoy, and Scott, with Spock the ranking officer. McCoy points out to Spock that this is his first command, and Spock replies, "I realize that command does have its fascinations, even under circumstances such as these, but I neither enjoy the idea of command, nor am I frightened of it. It simply exists, and I will do whatever logically needs to be done."
Taurus II turns out to be inhabited by people in goofy yeti costumes who throw even goofier spears, killing two red-shirts (who are, anyway, wearing yellow shirts). Spock tries to logically deduce what the yetis will do, and of course he gets it wrong, since the yetis haven't developed the sort of slave-supported leisure class to have hammered out formal principles of logic.
Stuffy Federation man says they've run out of time, but Kirk engages in malicious compliance and leaves under impulse. Scotty gets the Galileo into orbit, and in an act of logical desperation, Spock jettisons their remaining fuel and ignites it. The Enterprise gets the signal and rescues them.
Commentary
The original series has four fundamental kinds of episodes: enthralling philosophical pieces like "The City on the Edge of Forever," fun episodes like "Shore Leave," monster episodes like "Catspaw," and then this kind: monster episodes with the thinnest veneer of intellectual complexity.
We learn once again why vulcans don't make great Starfleet captains. There is an interesting thread here, which the writers were not sophisticated enough to tug.
Spock's version of logic is one in which there are definite facts which, though the application of Definitely True Rules, can be used to derive other facts. Spock gets the facts wrong, and the yellow-shirts die. He makes relatively little allowance for this, until he chooses to make a desperate play to signal the Enterprise.
On the other hand, Kirk and McCoy end the episode making fun of Spock for saving the day with emotion. A more philosophically rigorous interpretation is that Spock, for a brief, fleeting moment, gained some appreciation for the nature of complexity—though he misses the deeper fact, that formal logic has nothing useful to say about complexity.
In a sense, it's less painful for me to look at this episode as one about yetis throwing spears at immature people wearing yellow Lycra shirts. Or put another way, and maybe you all will wheel out the pillory for this one, I vastly prefer Data to Spock as a Starfleet logician.
I'm sure you all know, we'll be revisiting the title quote, with far more feeling, in The Wrath of Khan.