The old saying goes, “starve a fever, and feed a cold”. The idea is that bacterial infections require glucose to grow and spread, so fasting would reduce the amount of glucose. But viruses don’t need glucose; and fasting seems to suppress the immune system during the fast (but with a fast rebound when you refeed).
Eating does seem to increase inflammation, in my experience with gout and injuries. When I have a gout attack, it will hurt more after I’ve eaten anything.
Fasting seems to increase the beneficial gut bacteria Akkermansia Mucinphilia, which helps to make the mucus lining of the intestines thicker - which helps prevent things from your digestive tract leaking into your bloodstream.
So I guess the answer is that “science” doesn’t really know for sure yet, but in some people’s personal experience it had helped. But it could also hurt others. (Fasting tends to increase diarrhea in people who are new to it)