"R’ Yochanan said nega’im and the death of children are not yisurim shel ahavah (Brachos 5b)."
Before getting to the meat and potatoes of why and which negaim are excluded, this whole concept of yisurim shel ahavah, afflications of love, needs explanation and is the subject of a fascinating machlokes. Rashi (Brachos 5a) writes that yisurim shel ahavah are pains G-d brings on the righteous in this world even though they have not sinned so that their reward in the World to Come will be greater than their deeds alone. The Ramban in Toras haAdam (p. 270-272 in the Chavel edition) does not cite Rashi by name, but takes issue with this whole concept of suffering without sin. Ramban writes that G-d does not afflict any person unless they have done something wrong to deserve punishment - “Ain yisurim b’lo avon”. But if all suffering is brought upon sinners alone, why are these pains called yisurim shel ahavah? G-d does not love sinners – he is, after all, punishing them! Ramban explains that G-d’s punishment cleanses the righteous from whatever minor iniquity they may be guilty of (Ramban writes that even sins done b’shogeg, of which the doer may be completely unaware, still blemish the soul and require expiation) so they may merit their full portion of the World to Come. Precisely because of G-d’s love He sometimes visits suffering on righteous people so that they may fully enjoy their portion after death.
The gemara (Sanhedrin 101) writes that when R’ Eliezer was sick his students came to visit him and all except R’ Akiva were upset at the state of pain they found him him. R’ Akiva explained that they were worried for naught, for as long as R’ Eliezer’s wine never spoiled and grain was bountiful, it might have been presumed that he was receiving all his reward in this world – now that we see his suffering, we know that he will receive reward in the World to Come as well. R’ Eliezer asked, “But Akiva, have I not kept any precept of the Torah?”, meaning, why would you think I would not get reward in the next world just because I did not suffer? To which R' Akiva replied, "There is no righteous person who has never sinned". Ramban offers a very convincing proof to his position from this episode. Why according to Rashi should R’ Akiva have ascribed the suffering of R’ Eliezer to sin and not yisurim shel ahavah done out of G-d's desire for R’ Eliezer to accrue even more merit? It seems from the gemara that ALL yisurim, even those occurring to the most righteous, must be the result of sin. Aside from this proof, I find Rashi very difficult to understand philosophically – doesn’t reward earned through suffering alone circumvent the entire idea of earning reward only through bechira? The Ramban builds a very convincing case - tzarich iyun on how to understand Rashi.