No one feels well when they have a virus or a cold. Whether it's a stomach bug or a nasty case of the sniffles, being sick is no fun. And your brain realizes this. That sense of lethargy, minor depression and feeling like you can't even summon the energy to wipe your nose isn't just due to whatever batch of germs has invaded your body. It comes from your brain as well, separate from whatever creeping crud you're trying to fight off.
It's because your brain and your immune system are related. They interact in some ways, and one way that's getting a lot of attention in research is how your social brain is impacted by the body's immune response. The brain intersects with the immune system via the vagus nerve. That nerve can detect cytokines which are given off by white blood cells that are trying to fight off infection. The response in the vagus nerve inhibits the social part of the brain, making you feel like staying in bed with ice cream and Netflix. A study in mice that had been surgically altered to have no vagus nerve showed that when sick, the mice without the nerve still socialized and ate regularly. Part of the "sickness effect" as it's called is likely due to evolution, where humans developed a response of staying home and away from people as a way to keep germs from spreading.