OK has been traced to a 19th century Boston Morning Post article where a writer was satirizing the "new" craze of abbreviations. The more things change, the more they stay the same, I guess.
Rachel Newer at Smithsonian Magazine has pulled together a number of sources tracing the origin of OK to an article by Charles Gordon Greene in 1839. Greene was satirizing poor grammar and spelling — OK stood for "Oll Korrect" by his reckoning.
This use was found by etymologist Allen Read, who went on the hunt for proof that OK was an American invention. Says The Economist in Read's 2002 obituary:
In his hunt for the origin of OK he was offered dozens of theories. The first to go were the European ones. They were appealing: Mr Read liked what he called "frolicsome" ideas. But they had no substance, he said. He was convinced that OK was American. He warmed to the idea that the popularity of Orrin Kendall biscuits, supplied to soldiers on the Union side in the civil war, had lived on as OK. He noted there was a telegraph term known as Open Key. But OK proved to have been used much earlier. Writing in American Speech in 1963, Mr Read said that he had come across it in the Boston Morning Post in 1839. In what was apparently a satirical article about bad spelling it stood for "Oll Korrect". The next stage in OK's popularity was when it was adopted by followers of Martin Van Buren, who in 1836 became the eighth president of the United States, and unsuccessfully stood for re-election in 1840, by which time he was widely known as Old Kinderhook, a nickname he derived from his home town. "Vote for OK" was snappier than using his Dutch name.
Mr Read showed how, stage by stage, OK was spread throughout North America and the world to the moon, and then took on its new form AOK, first used by space people and frowned on by purists. This being an exercise in the academic world, there remain some doubters. Some believe that the Boston newspaper's reference to OK may not be the earliest. Some are attracted to the claim that it is of American-Indian origin. There is an Indian word, okeh, used as an affirmative reply to a question. Mr Read treated such doubting calmly. "Nothing is absolute," he once wrote, "nothing is forever."
Setting aside the controversy of whether this really is the true origin of OK, it seems like the popularity came from Martin Van Buren's reelection campaign and then given life by, Good Magazine points out, James Gordon Bennett forging a document showing Andrew Jackson using and coining OK as an abbreviation of "Ole Kurrek."
That's a fair amount of unsavory action going on to get OK into our lexicography. It almost feels like, since it was first a joke and then a slur on Jackson's intelligence, it should only be used in an ironic way. Or seen as a phrase that's been reclaimed from its history. Regardless, it's hard to think of those two letters the same way now. I'm not OK with it.