It's not clearly stated, but there are a few things we can draw inferences from.
When Goku succumbs to the effects of the virus in the battle with Androids 19 and 20 and Vegeta arrives to save the day, he criticizes Goku for his recklessness, and specifically states that his use of the Super Saiyan form accelerated his susceptibility. We are told many times, especially during the Android/Cell saga (and beyond), that the Super Saiyan form is tiring and exhausting, and requires a great deal of energy be used to activate. So much so that Goku and Gohan dedicate their training for fighting Cell to figuring out how to sustain the form indefinitely, endure it better, and save on the activation energy. A training strategy that Vegeta is loathe to admit is really quite clever.
The Z-fighters in general are in premium shape and would be most resistant to viral infections (relative to the rest of the global population) by default. But elevated levels of stress and exhaustion bring down the efficacy of the immune system.
So what we can infer from this is that the other Z-fighters had strong enough immune systems to fight it off, but Goku's failed when the virus opportunistically exploited the downsides of the Super Saiyan form. Vegeta is the only other fighter (not exactly a Z-fighter) we know that used a similarly, if not even more, exhausting training regimen and combat form. But he spent a great deal of his training time in outer space punching rocks, so may have simply avoided transmission from Goku or others by practicing the ultimate in social distancing.
There's also the simple fact that Goku is a Saiyan and not a Human, like the rest of the Z-fighters. The particulars of his immune system may alter his susceptibility (that it could infect two different species, Saiyan and Human, is a bit surprising and may have taken time to mutate to transfer from one to the other). Vegeta is, again, spared by social distancing. And Goku's family is, presumably, spared by being human or half-human. Piccolo is presumably spared by being Namekian and having inherited Eternal Youth from his father, and just generally spending most of his time meditating on rocky spires in the middle of nowhere.
Finally, most of the Z-fighters don't actually spend that much time together. They usually train on their own or with a fixed partner, and come together only to deal with new threats or special occasions (such as celebrating victory over such a threat). Goku's only real training partners are Gohan, Piccolo, and Krillin, most of which is either done on Roshi's Island or in a wilderness devoid of other people; Goku and his family themselves live in the middle of nowhere. Tien and Chiaotzu train together but separately from the others and in general isolation; Yamcha is a lone wolf who started as a desert bandit afraid of nothing but talking to women; Yajirobi hides with Korin, etc. So most of them aren't even exposed all that often to each other, or even other humans. This is particularly true in the time-skip to the arrival of the androids, as everyone went off to train in their own ways (if at all).
So, again, social distancing seems likely to have protected everyone, with Goku being the one unfortunate soul for which it didn't work out. Probably by random bad luck, as it's not a 100% surefire protection, but also possibly because Chi-Chi actually makes him go out and do stuff in public like getting a job, thus elevating his exposure. Whereas Krillin doesn't yet have a family or known job at this point, and Vegeta mostly just trains and doesn't even spend much time with his own family yet.