One of Nietzsche’s core concepts is the thought that you should live in such a way that the life you live can be repeated over and over again without change. You could do this by accepting life as it is and also start making decisions with this idea in mind. In his work, Nietzsche tries to show you life as it is, including all the “tricks” we use to sugarcoat reality, like hope in an afterlife or a purpose here on earth. Most of these hopes and purposes are sold by religions and political systems; they try to give their visions, and they often compete with each other in violent ways; it is bad for the world and all of us individually. The eternal return is a thought experiment that can help you when you want to find out how much you can live without reason and purpose but just for the beauty and miracle of it.
This quote is one of the first times Nietzsche speaks about this concept; you can read more on Wikipedia and in many other places in Nietzsche’s writings.
The Gay Science
Book Four: St Januarius 341 The heaviest weight. – What if some day or night a demon were to steal into your loneliest loneliness and say to you: ‘This life as you now live it and have lived it you will have to live once again and innumerable times again; and there will be nothing new in it, but every pain and every joy and every thought and sigh and everything unspeakably small or great in your life must return to you, all in the same succession and sequence – even this spider and this moonlight between the trees, and even this moment and I myself. The eternal hourglass of existence is turned over again and again, and you with it, speck of dust!’ Would you not throw yourself down and gnash your teeth and curse the demon who spoke thus? Or have you once experienced a tremendous moment when you would have answered him: ‘You are a god, and never have I heard anything more divine. ‘ If this thought gained power over you, as you are it would transform and possibly crush you; the question in each and every thing, ‘Do you want this again and innumerable times again?’ would lie on your actions as the heaviest weight! Or how well disposed would you have to become to yourself and to life to long for nothing more fervently than for this ultimate eternal confirmation and seal?