The wound that Magwitch receives on the top of his head and the water that Magwitch must have swallowed were contributing factors to his decline in health, along with the internal injuries from Compeyson.
In reading, you will note that there must have been some sort of bacterial infection because Pip falls ill shortly after visiting Magwitch. The communication of some bacterial diseases is such that Magwitch's bacterial infection could have been communicated to Pip just by Pip breathing the same air as Magwitch. Pip's sickness was caused by bacterial infection "I had a fever and was avoided, that I suffered greatly, that I often lost my reason, that the time seemed interminable, that I confounded impossible existences with my own identity"
Pip's disease was communicable, as evidenced by the fact that he was "avoided" and left alone so that those who had reason to look in on him would not get sick also. The severity of Pip's fever gives the reader a look at how terrible bacterial infection could be, because Pip says that he "often lost his reason."
The sicknesses of Magwitch and Pip were not without comforting moments, as shown by Pip staying with Magwitch during his sickness, and Joe taking care of Pip during his.
When Pip gets sick, he has Joe to comfort him during his time of need. Pip asks Joe if he has been watching Pip for the duration of Pip's sickness, and Joe replies, "pretty nigh, old chap".
Since we know what happened to Pip in the end, we can conclude that Magwitch may have suffered the same fate.