The philosopher Brian Leiter notes the relationship between Nietzsche's life experiences and intellectual preoccupations:
The influences of Nietzsche’s own life on the philosophy are very dramatic. Some of them have to do with the intellectual biography, of course – what he studied, what he read et cetera. But I think probably the crucial fact about Nietzsche’s life is that when he writes about suffering he’s not a tourist. He’s writing about something he knows very intimately. He understands from his own experience the effect of suffering on the mind, on creativity and on one’s attitude to life generally. And if there’s a central question in Nietzsche it’s the one he takes over from Schopenhauer – namely, how is it possible to justify life in the face of inevitable suffering? Schopenhauer comes up with a negative answer. He endorses something like a stereotype of the Buddhist view: The best thing would not to be born, but if you’re born the next best thing would be to die quickly. Nietzsche wants to repudiate that answer – partly through bringing about a re-evaluation of suffering and its significance.
The reasons for Nietzsche's emphasis on suffering?
He was the proverbial frail and sickly child. But the real trouble started in his early 30s, the 1870s, when he started to develop gradually more and more physical maladies – things that looked like migraines, with nausea, dizziness, and he would be bedridden. It got so severe that he had to retire from his teaching position at the age of 35. So he spent the remainder of his sane life, until his mental collapse in 1889, basically as an invalid travelling between different inns and hotels in and around Italy, Switzerland and southern France, trying to find a good climate, often writing, often walking when his health permitted, but often bedridden with excruciating headaches, vomiting, insomnia. He was trying every self-medication device of the late 19th century. He had a pretty miserable physical existence. His eyesight also started to fail him during this time. Through all this he usually managed to continue to write and read, despite these ailments. So he really knew what suffering was.
In retrospect, there’s reasonably good evidence that he had probably at some point contracted syphilis and that the developing infection might have been responsible for these maladies. Though his father had also died at an early age, so there may have been some familial genetic component as well.