Use "___ had been ___" when:
- you're talking about something that happened in the past
- there was something that happened even before that
- it was a continuing situation
In the example above, the speaker is talking about her grandmother's recent death. Her grandmother's health problems happened before that, and were ongoing. Here's another example:
Something funny happened to me last week. I was sitting in a coffee shop. I'd been waiting there for my sister for 30 minutes. Then I get a text message from her saying "Where are you!?"
Sentences with "had ___ed" are a kind of "double past". In English, you can talk about the past, present, and future from your perspective now. But you can also talk about the past, present, and future in relation to whatever situation you're describing:
I had done it.
I was doing it.
I was going to do it.