Nietzsche may have contracted syphilis as a student (some think this was the cause of his madness) and endured periods of illness during his adult life, which forced him to resign from the University of Basel. After the completion of Ecce Homo his health rapidly declined until he collapsed: in Italy, wearing only underwear, he tearfully embraced a horse because it had been beaten by its owner. From that moment on he never recovered. Nietzsche spent the last ten years of his life insane and unaware of the immense success of his works.
The cause of Nietzsche's condition has to be regarded as undetermined, as doctors later in his life said they were not so sure about the initial diagnosis of syphilis, since he lacked typical symptoms. Other possibilities could be a tumor or an endogenous illness, possibly paranoia.
1872 The Birth of Tragedy
1876 Untimely Meditations
1878 Human, All Too Human
1881 Daybreak
1882 The Gay Science
1885 Thus Spake Zarathustra
1886 Beyond Good and Evil
1887 On the Genealogy of Morality
1888 The Case of Wagner
1888 The Antichristian (publ in 1895)
1888 Nietzsche contra Wagner (publ in 1895)
1888 Ecce Homo (publ in 1908)
1889 The Twilight of the Idols
In 1901 The Will to Power, a highly selective collection of notes from various notebooks, not intended for publication by Nietzsche himself, was released by his sister. She was associated with the Nazis in the 1930s, and is responsible for selective quoting and abuse of his philosophy in Nazi ideology.