To commemorate the 200th birthday of Darwin, Science has featured several articles on the origin of several physiological processes. I have posted one previously on the origin of the nervous system. This one focuses on the origin of the immune system. It received mixed reviews from the science community if you have read recent editions of Science.
As a side note, immune responses also have a circadian rhythm, and remain active during sleep.