Someone has an illness which is inevitably going to kill them. Why? Imagine following situation: A person who thinks of themself as a good person, meaning they are mostly nice to people and act and think almost always morally. Said person is diagnosed with an illness that has no cure and is inevitably going to kill them in, say, a year. How would a Buddhist explain this? 

I already know about the four noble truths as well as the noble eightfold path. Also I know that one could explain it with the concept of rebirth. But I'd like a more in-depth explanation and I'm interested if there are other ways of explaining it or if I am wrong with the information I already have.
The way my teacher taught me, he said most (but not all) illnesses are karmic results of attachments. In his explanations, these attachments are often tendencies that are passed from generation to generation - from parents to children. So most diseases have roots in attachments that ran strong in previous generations of the family.

In my teacher's explanation, a disease is always a way to get rid of attachment, either voluntarily - through spiritual growths, or forcefully - through loss and death.

If a given member of the family has a problem with attachments that were passed on, and this time can spiritually evolve enough to abandon the attachments and grow beyond them, then the karmic disease can be circumvented or quickly healed.