A and an function primarily as the indefinite forms of the grammatical article in the English language.
An is the older form, now used only before words starting with a vowel sound (and sometimes words beginning with an H sound in an unstressed syllable as in an historic event, but this usage is fading).
Indeed, the N has wandered back and forth between words beginning with vowels over the history of the language, where sometimes it would be a nuncle and is now an uncle. The Oxford English Dictionary gives such examples as smot hym on the hede with a nege tool from 1448 for smote him on the head with an edge tool and a nox for an ox and a napple for an apple. Sometimes the change has been permanent. For example, a newt was once an ewt (earlier euft and eft), a nickname was once an eke-name, where eke means "extra" (as in eke out meaning "add to"), and in the other direction, an orange was once a norange.
In addition to serving as an article, a and an are also used as synonyms for the number one, as in "make a wish", "a hundred". An is an older spelling of "one".
A and an are also used to express a proportional relationship, such as "a dollar a day" or "$50 an ounce".
See also the.