Role of the immune system in the control of thyroid function