Friedrich Wilhelm Nietzsche's health was never good. Plagued by headaches most of his life (and being a bit of a hypochondriac as well), his reclusive bachelor lifestyle isolated him from all but his most devoted friends and family members. Nietzsche's numerous letters to his mother, sister, and close friends were filled with frequent complaints about nausea, headaches and sleeplessness which left him unable to work for long periods of time. One biographer suggested that his letters from that period of his life showed him as a "young, touchy, prematurely old, young man" whose medical complaints seemed to worsen whenever he failed to get his own way in something. These health problems can't have been helped by his bizarre regimen of special diets (vegetarian or otherwise), patent medicines (he insisted on doctoring himself for his various complaints), and frequent worries with only occasional trips abroad to relax.
Despite becoming a professor of philology at the University of Basel at the age of twenty-four and proceeding on to a brilliant academic career, Nietsche was forced to resign by 1879 due to health problems. After establishing himself as an independent author and philosopher, he lived in various cities in Switzerland, France, and Italy in search of a more suitable climate. It was also during this period when he produced some of his most remarkable works, including Thus Spoke Zarathustra, Beyond Good and Evil, and The Antichrist. He relished the notoriety that his writing brought him and became friends with some of the leading artists and intellectuals of his day. Still, Nietzsche was often despondent because of his uncertain health and his own perceived sense of failure that his writing failed to win him the accolades he felt he deserved. While his philosophical writing (with over one hundred books) would eventually make him one of the dominant intellectual figures of his era, this fame would come far too late for him.
It's hard to say for certain when Nietzsche's final illness began. According to some sources, the breakdown occurred on January 3, 1889 when he was approached by two Turin policemen after causing a public disturbance and assisted in returning to his apartments (one anecdote relates that he had become agitated at seeing a horse being whipped). In reality, however, disturbing clues as to Nietzsche's declining mental state come from a series of increasingly bizarre letters to his friends and acquaintances dating back to the final months of 1888 (and likely earlier). The letters, now known as the Wahnbriefe ("Madness Letters") alarmed his friends greatly since they demonstrated just how disturbed the philosopher had become. The bizarre tone of the letters (in which he frequently referred to himself as "Dionysius" or "the Crucified" and rambled at length about his grandiose delusions) spurred his long-time friend Franz Oberbeck to travel to Turin.
Overbeck found Nietzsche in a bizarre state, being carefully watched over by his hosts. As Overbeck would later describe, Nietzsche was "ploughing the piano with his elbow, singing and crying his Dionysian glory". Returning with him to Switzerland, Overbeck was able to place his friend in a psychiatric hospital in Basel on January 10. The examining physician commented on Nietsche's grandiose symptoms ("claims to be a famous man and asks for women all the time") and gave an official diagnosis of "mental degeneration". I say official since the prevailing consensus was that the great writer was suffering from the effects of syphilis (although reliable diagnostic tests would not be available until decades later) which was largely a taboo topic in those days. His supposedly grandiose delusions likely played a role in that diagnosis (he was still relatively unknown by that point) and there was no real evidence that he had ever been treated for syphilis in the past.
By January 13th, Nietzsche's mother arrived to take charge of her ailing son. As the very proper widow of a Lutheran minister, Franziska Nietzsche had often been scandalized by her son's writing (including his "God is Dead" philosophy) but his surviving letters to her demonstrate the strong bond that they shared. Franziska made arrangements for her son to return with her to her home in Germany (over the clinic's objections). As a compromise, Friedrich was transferred to to the asylum in Jena where Franziska could visit him regularly. Since she was unable to afford first-class treatment for her son, only second-class treatment was available (no socialized medicine back then) although Friedrich hardly noticed the difference given his bizarre mental state. Being in the second-class ward meant that he was left largely to himself and the original syphilis diagnosis went unchallenged. He would remain in the Jena asylum until March 24, 1890 when Franziska discharged him to her home in Naumberg. For the remaining seven years of her life, Franziska dedicated herself to her son's care including taking him for long walks, talking with him, reading to him, and generally tending to his every waking need.