Why is "ain't" a contraction? What's it a contraction of?

Abe Lincoln used it, so it’s fine.

Since it’s a form of the verb “be”, it’s naturally a very tangled tale. I’m not an expert, so I offer the following for information only.

The online OED gives these earliest cites of “an’t”, “ain’t”, and “a’n’t” meaning “am not”

Obviously the first two mean “am not”. In the third, “ain’t” might be a contraction of “am I not”, except that the next word is “I”.

The OED also gives this cite of “a’n’t” meaning “are not” (earlier than “ain’t” meaning “am not”).