Spock's so out of character here it's not even funny.
Spock being out of character is rather the point, though. He's reverting to a passionate Vulcan like those of 5000 years ago, as a consequence of having gone through the Atavachron. McCoy evidently figures that out because humans aren't as compromised as Vulcans by the process. Evidently by comparison with the change that Spock undergoes, human nature is little different in the 23rd century from what it was 5000 years ago.
Dialog:
MCCOY: Are you trying to kill me, Spock? Is that what you really want? Think. What are you feeling? Rage? Jealousy? Have you ever had those feelings before?
SPOCK: This is impossible. Impossible. I am a Vulcan.
MCCOY: The Vulcan you knew won't exist for another five thousand years. Think, man. What's happening on your planet right now, this very moment?
SPOCK: My ancestors are barbarians. Warlike barbarians.
MCCOY: Who nearly killed themselves off with their own passions. Spock, you're reverting into your ancestors five thousand years before you were born!
SPOCK: I've lost myself. I do not know who I am. Can we go back?
ZARABETH: I don't know. I only know that I can't go back.
MCCOY: I know I'm going to try, Spock, because my life is back there, and I want that life.
One thing I like about the episode is that we hear this side of Spock:
MCCOY: You listen to me, you pointed-eared Vulcan.
SPOCK: I don't like that. I don't think I ever did, and now I'm sure.
Taking this line as part of the premise, what we're seeing and hearing are expressions of how Spock really feels.
The crux of the story is Spock's choice to sacrifice what he desires, which matters more than usual because in this case he feels free to express his feelings. In essence, he has to repeat the choice that ancient Vulcans made to favor logic over emotion. McCoy can see both sides, of passion on one hand and logic on the other. McCoy is even more logical than Spock in discerning the flaw in what Zarabeth is telling them about being unable to get back. This placing of McCoy in the middle between passion and reason makes him the bridge who helps Spock come back, and I see this middle between passion and reason as an intentional characterization of human nature generally.
For me, regressing to live in the past to escape death works as a metaphor on several levels. One, in escaping to the past, the Sarpeidons inject their vitality into the past, and that transference of vitality matches the recurring pattern in the episode of the peoples of the past being more passionate and savage than those in the present. Metaphorically, the Sarpeidons are stoking the passions of their own past. Two, the idea of a library in a civilization at the end of its existence is analogous to an old person reflecting back on their life, as suggested by the title. Even Zor Kahn being concerned with how he would be remembered fits the theme of narratives in a library. Romanticizing about the past is one of the more obvious themes of the episode.
I think this is one of the second tier episodes that had the potential to be among the best.