There has been quite a bit of study on the development of eyespots. How did they evolve is still unclear, but several experiments have elucidated the molecular mechanisms underlying their formation.
The Wikipedia page about eyespots gives a good basic introduction and some interesting references.
So, first of all, how does an eyespot form?
During the development of wings, eyespots arise at specific locations called foci (singular focus).
If you take cells from a focus in a developing wing, and transplant them into another region of the wing, an eyespot will develop at the transplanted site.
Adapted from: Pattern Formation on Lepidopteran Wings: Determination of an Eyespot - Nijhout, Dev. Biol, 1980
The photo on the left is a normal wing from an adult Buckeye butterfly, Precis coenia. In the middle and right photos, some cells of the big eyespots have been transplanted in a new position during development. As you can see, a third eyespot develops. Note that the middle photo is from an autograph, that is, the cells were transplanted on the same wing. This results in a shrinkage of the normal eyespot. In the right picture, instead, cells were transplanted in another individual, and this does not result in shrinkage of the eyespot.
The authors conclude that:
It is evident from these experiments that the development of the large eyespot on the forewing of Precis coenia depends on the presence of a small group of cells that lie at or near its center. This group of cells corresponds to a "focus": a small region, occurring in each wing cell, that is postulated
to be responsible for the induction of most color pattern elements in butterflies and moths (Nijhout, 1978). Cautery experiments establish an upper limit for the size of this focus in the neighborhood of 300 epidermal cells, though it is probable that the actual size of the focus is much smaller.
They further speculate that a specific morphogen may be involved:
The response of the eyespot pattern to cautery or transplantation of the focus is most readily interpreted if we assume that the focus is the source of a morphogen that is somehow able to induce synthesis of specific pigments.
The idea that a morphogen was involved has been confirmed in later years.
From: Development, plasticity and evolution of butterfly eyespot patterns - Brakefield et al., Nature, 1996
The focus is proposed to be a signalling source for a morphogen, the levels of which determine the pigmentation of surrounding cells. Recent investigations have indicated that regulatory genes, such as the Distalless homeobox gene, are specifically espressed in the eyespot focus.
During the development of the wing the expression of the Distalless (Dll) protein (shown in green in the picture) corresponds to the location of the future eyespots.
Several mutations exist that will provoke changes in the eyespots patterns. Some of this with the evoking names of Cyclops, Spotty and Bigeye were analysed in the paper.
Now, without going much into insects genetics (which is far from being my domain of interest), you can clearly see that, although the number, position and size of the foci are affected by the mutations, their position always correspond with an increased expression of Dll during development.
Left column: ventral hindwing patterns of a wild type (top), Cyclops (middle) and Bigeye mutants. Right column: forewing pattern in a wild type (top) and Cyclops mutant (bottom).
From the conclusion of the paper (bold mine):
The selection experiments on B. anynana rapidly produced dramatic differences in eyespot size which were due to genes of small phenotypic effect. The mutants described here show that genes also exist with large phenotypic effect on eyespot development (including size) that have no perceptible effect on other wing or body patterns. It is likely that the evolution of eyespot patterns in nature involves both genes with large and small effects on eyespots development. [...]
These observations suggest that the regulation of the eyespot developmental pathway is such that eyespot patterns can evolve rapidly and independently of other wing-pattern elements and body structures.
Finally, another interesting read is:
Wings, Horns, and Butterfly Eyespots: How Do Complex Traits Evolve? - Monteiro and Podlaha - PLoS Biol., 2009
where the authors propose that:
Complex traits require co-ordinated expression of many transcription factors and signaling pathways to guide their development. Creating a developmental program de novo would involve linking many genes one-by-one, requiring each mutation to drift into fixation, or to confer some selective advantage at every intermediate step in order to spread in the population. While this lengthy process is not completely unlikely, it could be circumvented with fewer steps by recruiting a top regulator of an already existing gene network, i.e., by means of gene network co-option. Subsequent modifications of the co-opted network could further optimize its role in the new developmental context.