Molecular mimicry is a theory in immunology that autoimmune diseases are caused by B-cells and T-cells reacting to harmless molecules in the body that resemble the molecules associated with pathogens. It provided an explanation for the previous problem that, in general, the immune system can distinguish foreign material from material that makes up the patient's own body.
Although molecular mimicry cannot explain all autoimmune conditions, it goes a long way in explaining why some autoimmune conditions develop after an illness. Here, the pathogens have molecular sequences that can be similar to those that are properly in the body and the antigens for the illness continue to react to those molecular sequences after the illness is no longer in the body.
One of the remaining mysteries is that such mimicry should not, as a matter of probability, occur in more than one out of every 64,000,000 illnesses due to the unlikelihood of two sequences of consequence matching each other. It is believed that molecular structure may be more important than molecular chemistry in this regard.