's presentation of eternal recurrence in "Also Sprach Zarathustra" derives from a moment in which he was standing in the mountains in Italy
. The crispness of the blue of the sky, the briskness of the air, all called forth for him a sense of complete affirmation
, an epiphany
of utter willingness to experience this
as it is.
He began to think that this was the central matter of how to live: being willing to live each moment of one's life over again, endlessly.
Whether or not he intended eternal recurrence to be understood literally or not is a matter of some scholarly dispute.
(I believe he wrote of the event in the mountains in "Ecce Homo" but am uncertain as I have not read Nietzsche in over three decades.)