Bernie Mac suffered from sarcoidosis, which apart from being what "it" isn't on "House, M.D.", is some sort of lung condition.
Bernie was reportedly on a new medication that lowered his immune system, so he got pneumonia, for which he was hospitalized.
Hospitals being what they are, he picked up a second strain of pneumonia while under their care, and died of the complications of the overwhelming attacks on his system.
This whole model of "let's nearly kill you so that we can kill the bug, then somehow revive you" seems rather lacking. Especially when the "nearly" becomes "actually".
The medical system failed Bernie Mac, as it has failed others less famous but just as loved.