Tell all of the immune cells that they should seriously consider killing themselves. Most do, something like 1/3 remain. The cells that don't are usually healthier and less likely to be auto-reactive. Cells that are old or damaged are more eager to kill themselves, and their molecules are used for more important things during the fast.
Then when the food comes back, stem cells are activated to replenish the immune cells over the course of a few days of refeeding. The new cells are healthy and not yet auto-reactive.
This. Autophagy. It's well studied