That Spock quote is from Star Trek II, Wrath of Khan. Later, in Star Trek IV, The Voyage Home Chekov is in grave danger but to rescue him would put their mission at risk which would endanger many more people. This conversation occurs:
UHURA'S VOICE
They report his condition as critical;
he is not expected to survive.
BONES
Jim, you've got to let me go in there!
Don't leave him in the hands of
Twentieth Century medicine.
KIRK
(already decided, but:)
What do you think, Spock?
SPOCK
Admiral, may I suggest that Dr.
McCoy is correct. We must help
Chekov.
KIRK
(testing)
Is that the logical thing to do,
Spock...?
SPOCK
No, Admiral... But is the human
thing to do.
KIRK
(takes a beat)
Right.