Here's a quiz: let's say you're setting off to see the world and aside from please and thank you in a smattering of languages you pretty much only know English. What is the one word that most of the people you encounter will also know?
That's right. It's OK.
Yep. It's very probably the most widely recognized word in the world. And its origin story is literally a joke.
The definitive text on the subject is by professor Allan Metcalf, whose OK: The Improbable Story of America's Greatest Word, based on the research of historian Allen Walker Read, was published in 2010. Metcalf traces the word's birth to a bit of jocular text in an 1839 article in the Boston Morning Post—a little jab from one newspaper editor to another, suggesting that his cohort in Providence, Rhode Island, should sponsor a party for some boisterous Boston lads who might be stopping by his town:
... he of the [Providence] Journal, and his train-band, would have the 'contributions box,' et ceteras, o.k.—all correct—and cause the corks to fly…"
But let's back up for a minute and establish our setting. Newspapers in the 19th century existed before the advent of wire services, and American newspapers got most of their out-of-town news from other newspapers they exchanged copies with. The papers weren't cramped for space, and they'd also print humor, poetry, fiction, and jabs at other newspapers. The quote above is part of a humorous reply to an item reprinted from the Providence paper.
Despite plenty of space, there was an abbreviation fad in newspapers of the time that might remind one of our own time. Perhaps a friend has sent you an electronic message containing brb, for "be right back"? Or maybe you've assessed an article as TL;DR? Let us present for comparison the 1839 New York newspaper report of a fashionable young woman remarking to her male friend "O.K.K.B.W.P.": her alphabetic litany was answered with a kiss and reported to translate as "one kind kiss before we part." Take that, Internet.
The 1820s and 1830s shared another linguistic fad with today: an appreciation for deliberate misspellings. (Kewl, rite?) This trend, which had humorists adopting now-cringey bumpkin personas with ignorance manifested in uneducated spellings, turned no go into know go and no use into know yuse (lol). Abbreviations were not immune, and no go became K.G.. So too all right became O.W., as an abbreviation for oll wright. And all correct became o.k., as an abbreviation for oll korrect.
Although OK became one of the more commonly used initialisms, it might have passed into oblivion when the linguistic fad had passed if not for the presidential election of 1840, when Martin Van Buren was given the nickname of "Old Kinderhook" because of his hometown of Kinderhook, NY. The Van Buren stans who joined "OK Clubs" nationwide were themselves, they proclaimed, "OK." Their campaign was memorable enough to have both popularized the word and to have hijacked the story of its origin: there are today still those who believe that "Old Kinderhook" is the original meaning of OK.
As OK spread (helped along by the advent of the telegraph), its origin story was a topic of much speculation. "Old Kinderhook" persisted, and various linguistic ancestors from various languages were also proposed, with forebears from Latin, Greek, Scottish, French, Finnish, Anglo-Saxon via Swedish, Mandingo, and Wolof all being offered. The most persistent of these ancestors was the Choctaw word okeh. This etymon was suggested in 1885, with Andrew Jackson supposedly having borrowed the word from members of the Choctaw tribe. Woodrow Wilson was a believer: he wrote okeh on papers he approved. He was asked why he did not use O.K. "Because it is wrong," he replied.
O.K. is of course not wrong. And speaking of "wrong," OK and okay aren't wrong either; they are the dominant forms, though the lowercase ok is also fully established.
Although the longer okay may look like the more reputable member of the language, it's not, as we've seen, justified by etymology. It has its supporters, though, with Louisa May Alcott being among the early adopters:
One of us must marry well. Meg didn't, Jo won't, Beth can't yet, so I shall, and make everything okay all round.
— Little Women, 1868-9
As Professor Metcalf notes in an illuminating blog post all about the okay spelling, the 1880 edition of Little Women included neither okay nor OK, opting instead for the word cozy. Um, OK.