The reaction of the immune system to pathogens but not food antigens and commensal bacteria.