Up until very recently, it was thought that the holes in Swiss cheese came from bacteria that forms during the aging process. This theory was developed by William Mansfield Clark, a Department of Agriculture chemist, in 1912. This specific type of bacteria is unique to Swiss cheeses due to the type of starter used and the precise temperature the cheese wheels are stored at during the aging process. The bacteria in Swiss cheese wheels give off carbon dioxide, and the carbon dioxide forms bubbles in the cheese. When the bubbles "pop," holes—also called "eyes"—are created.
Now, however, this theory is being debated.
The Hay Theory
Agroscope, a Swiss agricultural institute, believes that tiny specks of hay are responsible for the holes in Swiss cheese. When cheese is made in barns using buckets, there is a likelihood of hay particulates making it into the buckets of collected milk, which then cause holes to form in the cheese as it ages. It is these specks of hay that cause a weakness in the structure of the curd, allowing gas to form and create the "eyes." (It actually doesn't have to be hay—any particulate matter can cause the formation of holes.)
Whereas William Mansfield Clark used glass cylinders and mercury to create an apparatus to capture gasses and develop his theory, Agroscope used a CT scanner, following the cheese ripening process for 130 days. The cheese-making community has believed that hay has been the culprit all along, and now they have scientific proof.
Due to the modernization of dairy farms, however, Swiss cheese may not have as many eyes as it used to. As milking methods have become more automated and antiseptic, and fewer hay particles drop into the milk, the size of the holes have decreased and the number of holes in Swiss cheeses, such as Appenzeller and Emmental, have declined.
You can read more about this discovery on CNN's website in the article, "What Makes Swiss Cheese? You Don't Have the Hole Story."