It is the same reason people go to work when they know they are sick. And go to social events. And go to school. And jump on a plane.
There is always an incentive to make sure you go to work...or school...or a social event...or jump on a plane, and by corollary, a disincentive to stay home.
The basic reasons cover the spectrum, but the outcome for following the incentive (and avoiding the disincentive) in these cases is always bad, because everyone else gets sick.
As a manager, I encourage my team to stay home when they don’t feel well. Have a fever, don’t set foot in the office. I keep a can of disinfectant spray handy and spray our area weekly. Work will be there tomorrow.