Most thyroid problems are caused by an underlying, often tissue-specific, autoimmune problem. The same trigger (an attack on thyroid cells by the immune system) can produce opposite clinical outcomes - either Graves' Disease (hyperthyroidism) or Hashimoto's Thyroiditis (hypothyroidism). Since they're both autoimmune disorders affecting the thyroid, I'm going to treat them as such, together.
First, I'll briefly cover autoimmune disorders in general for those who aren't familiar. The main job of your immune system is to get rid of things that don't belong in your body. To do that job without doing more harm than good, it's vitally important that it can distinguish self from nonself. When it gets that wrong, such as with pathogens that masquerade as healthy cells, massive failure ensues. Such is the case with autoimmune problems, where the immune system mistakenly identifies normal, healthy cells as nonself and attacks them. This can be systemic as in lupus or multiple sclerosis, or tissue-specific as in Graves' or Hashimoto's.
Many autoimmune problems are often comorbid with each other, and Hashimoto's and Graves' are no exception. Perhaps the most common disease found alongside autoimmune thyroid problems is celiac disease. This presents several interesting possibilities. One suggestion has been that celiac is itself an autoimmune disease. If so, its comorbidity with thyroid disease relative to other autoimmune diseases remains to be explained. Another, more intriguing possibility is the better established fact that celiac disease fosters malabsorption of several nutrients, especially vitamin D. This is all the more interesting because celiac itself may be caused by a deficiency in vitamin D, which protects the intestinal lining that's damaged in celiac cases.
So what's the link? What do vitamin D or celiac have to do with autoimmune thyroid disease? Vitamin D is crucial to the proper functioning of the immune system, and the volume of evidence that vitamin D deficiencies play a major role in autoimmune disease is overwhelming. Even very severe autoimmune diseases like lupus and multiple sclerosis can be completely reversed with intensive vitamin D supplementation therapy, but that can result in hypercalcemia. Vitamin D supplementation even completely prevents type 1 diabetes in rats bred to get the (autoimmune) disease.
Is vitamin D deficiency prevalent enough to explain the large numbers of autoimmune sufferers? That depends a lot on who's defining the deficiency. The FDA says that 200 IUs per day is adequate, and that's after raising it more than once. Many doctors, though, are pushing for it to be raised much further, to 1000 IUs per day or more, and insisting that very few people actually get sufficient vitamin D.
The next obvious question is how to fix a vitamin D deficiency. Assuming you're not absorption-impaired and you get enough dietary fat to make use of this fat-soluble vitamin/hormone, supplementation may suffice, but I prefer a more natural approach. Foods like meat, butter and eggs will go a long way, but if some of these researchers are right, even if you ate these things exclusively you may not be getting enough vitamin D for optimum health. For that, many of them say, you must also get plenty of exposure to sunlight. Be aware that sunlight, while catalyzing the conversion of cholesterol to vitamin D, also breaks down folate and thus increases your risk of melanoma if you're folate-deficient, but that's a topic for another article.