There will always be a tradeoff in terms of resource allocation between reproduction and self maintenance. Since worker ants forego reproduction to perform other roles (gathering resources, caring for young etc.) within the colony, it makes sense that this would favour a longer lifespan. This idea works for most animals (i.e. higher reproduction = lower lifespan across species in general) and is well documented (Partridge et al. 1987, Gems & Riddle 1996 (PDF link), Westendorp & Kirkwood 1998 - to name a few). However the relationship is reversed in eusocial animals: the queens of ants, some bees and naked mole rats (which are all eusocial) tend to be longer lived than their sterile workers (Hartmann & Heinze 2003). Aging patterns within ants and other eusocial organisms are a very popular research topic at the moment, but the mechanisms causing differences between social castes are not fully understood.
Eusociality is strongly associated with increased lifespan, indeed many studies on the evolution of aging have focussed on eusocial animals which have appeared to overcome aging effects to an extent (Keller & Genoud, 1999, Buffenstein 2005). The naked mole rat is one of very few species of eusocial mammals and the relationship between its lifespan and body mass is very dissimilar to that of other rodents (ignore the bat points):
Image from Buffenstein & Pinto (2009).
If a queen has a longer reproductive lifespan then over the course of its life it will create a higher number of offspring. This will cause their increased longevity genes to be more prevalent in the gene pool over time - as long as they are able to reach the limit of their reproductive lifespan and are not killed by externalities (accident or attack) in the meantime. Therefore this trait (longer reproductive lifespan) will be selected for as long as the queen is protected.
Within eusocial colonies, there is often a protective environment (Buffenstein & Jarvis 2002): there is usually a physical structure (nest or burrow); symbiotic bacteria and/or fungi creating a more hygienic microflora; and queens are also protected by other castes. This gives queens a lower incidence of death due to accident or attack which (from the reasoning in the previous paragraph) supports the selection of a longer reproductive life. This is likely to lead to longer lived workers since they share the same genes.
However queens do tend to live much longer than their workers (O'Donnell & Jeanne 1995). This is probably due to their reproductive role. All the ants in the colony are investing in reproduction (whether by physically giving birth to young or by providing it with food and protection) therefore the normal relationship (reproduction and lifespan tradeoff) mentioned at the start is not relevant, but since the queen is the only individual reproducing, it will be the only one for whom lengthened lifespan is beneficial evolutionarily.
A mean lifespan of 20 years has been observed in Formica exsecta, and a maximum lifespan of 28.5 years observed in Lasius niger. Pogonomyrmex owyheei has an observed maximum of 30 years, and mean of 17 years. These (and many more) figures were obtained from a review by Keller (1998).
Other references on this subject include (Svensson & Sheldon 1998), (Keller & Genoud 1997) (PDF link), (Calabi & Porter 1989), and (Amdam & Omholt 2002).
References
Amdam, G.V. & Omholt, S.W. (2002) The Regulatory Anatomy of Honeybee Lifespan. Journal of Theoretical Biology, 216, 209–228.
Buffenstein, R. (2005) The naked mole-rat: a new long-living model for human aging research. The Journals of Gerontology Series A: Biological Sciences and Medical Sciences, 60, 1369–1377.
Buffenstein, R. & Jarvis, J.U.M. (2002) The Naked Mole Rat--A New Record for the Oldest Living Rodent. Sci. Aging Knowl. Environ., 2002, pe7.
Buffenstein, R. & Pinto, M. (2009) Endocrine function in naturally long-living small mammals. Molecular and cellular endocrinology, 299, 101–111.
Calabi, P. & Porter, S.D. (1989) Worker longevity in the fire ant Solenopsis invicta: Ergonomic considerations of correlations between temperature, size and metabolic rates. Journal of Insect Physiology, 35, 643–649.
Hartmann, A. & Heinze, J. (2003) Lay eggs, live longer: division of labor and life span in a clonal ant species. Evolution, 57, 2424–2429.
Keller, L. (1998) Queen lifespan and colony characteristics in ants and termites. Insectes Sociaux, 45, 235–246.
Keller, L. & Genoud, M. (1997) Extraordinary lifespans in ants: a test of evolutionary theories of ageing. Nature, 389, 958–960.
Keller, L. & Genoud, M. (1999) Evolutionary Theories of Aging. Gerontology, 45, 336–338.
O’Donnell, S. & Jeanne, R.L. (1995) Implications of senescence patterns for the evolution of age polyethism in eusocial insects. Behavioral Ecology, 6, 269–273.
Svensson, E. & Sheldon, B.C. (1998) The social context of life evolution history. Oikos, 83, 466–477.