It is considered by many to be a shibboleth; its frequent use is said to be a marker of basilectal --- which is to say, lower class --- speech. This judgment, hard to justify on etymological or grammatical reasons, remains a widespread belief, and is to some extent self-perpetuating, since both teachers and educated parents discourage the use of the term.
Ain't arose towards the end of an eighteenth century period that marked the development of most of the English contracted verb forms such as can't, don't, and won't. The form first appears in print in 1778. It was preceded by an't, which had been common for about a century before then. An't appears first in print in the work of Restoration playwrights: it is seen first in 1695, when William Congreve wrote I can hear you farther off, I an't deaf, suggesting that the form was in the beginning a contraction of "am not". But as early as 1696 Sir John Vanbrugh uses the form for "are not": These shoes an't ugly, but they don't fit me. At least in some dialects, an't is likely to have been pronounced like ain't, and thus the appearance of ain't is more a clarified spelling than a new verb form; in some dialects of British English, are rhymed with air, and a 1791 American spelling reformer proposed spelling "are" as er. Ain't in these earliest uses seems to have served as a contraction for both am not and are not; for which see be.
During the nineteenth century, with the rise of prescriptivist usage writers, ain't fell under attack. The attack came on two fronts: usage writers did not know or pretended not to know what ain't was a contraction of, and its use was condemned as a vulgarism --- here meaning a part of the speech of the lower classes. Perhaps partly as a reaction to this trend, the number of situations in which ain't was used began to expand: some speakers began to use ain't in place of is not, have not, and has not.
Ain't would solve one logical problem of English grammar; it would serve as a useful contracted inverted form in the question Ain't I? Many prescriptivists prefer Aren't I in this situation; this is illogical in conjugation, and for speakers of non-rhotic dialects may only be a baroque spelling of one possible pronunciation of the eighteenth century an't. Ain't is also obligatory in some fixed phrases, such as Say it ain't so. Ain't may also be mandatory if you accept African-American vernacular English as an alternative set of grammatical norms. However, most usage writers continue to condemn "ain't."