It goes all the way back to Middle Ages, a time when few people could write and read. In my opinion, it has to do with signing a letter using XOXO to mean hugs and kisses. Some sources claim that X has religious connotations and mean 'Christ', so by signing X, you're actually saying In Christ's name, I assert___. Some sources say that the signee would then kiss the X to demonstrate that what was written in the document was true.
According to Wikipedia:
The common custom of placing "X" on envelopes, notes and at the bottom of letters to mean kisses dates back to the Middle Ages, when a Christian cross was drawn on documents or letters to mean sincerity, faith, and honesty.
The Wikipedia article on the letter X says that X is sometimes used as an abbreviation for 'Christ', so 'Xmas' means 'Christmas'.
According to another article on Today I found, “X” first started being used as a substitute for “Christ” by religious scholars about a millennia ago, which is actually how we ultimately got Xmas as an alternative name for Christmas.
From Today I Found Out:
Signing letters with an ‘X’ dates back to the Middle Ages. At this time, many couldn’t read or write, so this was an easy way for someone to sign something and, particularly in legal documents, assert that whatever was said in the document was true. Specifically, the X represented a Christian cross/Christ at this time, so by signing X, you’re essentially saying “In Christ’s name, it’s true / I assert.”
The same article also associates the use of O with illiterate Jewish immigrants who refused to use X as a signature:
If you weren’t satisfied with the lack of definitiveness of the “X” part of things, you’ll be even less so with the “O” symbolizing the hug. The most popular theory here pre-supposes the reasonably likely X / Christ signing theory is correct. The theory then goes that the “O” is of North American descent, with illiterate Jewish immigrants who couldn’t sign their own John Hancock arriving to the U.S. and refusing to sign with the X (Christ/Cross) and instead using a circle on documents for a signature. (Incidentally, many etymologists believe this is how the derogatory racial slur for Jewish people “kike” came about, “kikel” being the Yiddish word for circle- Jews being associated with circles as that’s how illiterate Jews would sign, rather than with the “Christian” X.)
From Mental Floss:
Because many people in the Middle Ages could not read or write, they would sign important documents with an “X," which was both a simple mark to make and a reference to the Christian cross. The signee would then kiss the "X" to demonstrate his sincerity and that what was written in the document was true—in much the same way that Christians kissed the Bible to display their belief in Christ. Besides referencing the actual cross itself, the “X” alluded to the early Christian symbol called the Chi-rho.
Mental Floss also claims that the use of O is of Jewish origin:
Tracing the origin of how the “O” came to represent a hug is more difficult. One possible explanation is that Jewish immigrants, upon arriving in the U.S., used the symbol in place of a signature, similar to the way the "X" was used by Christians. Instead of using an "X," which invoked Christ—a figure that did not align with Jewish beliefs—illiterate Jewish people arriving in the U.S. would sign documents with an “O.”
Somewhere in the past, the symbol transformed from a religious one to a common romantic one. Back in the Middle Ages, people who couldn't read or write would sign documents with a simple "X." People would also kiss their "X" signature, kind of like sealing the deal.
Marcel Danesi, a professor of linguistic anthropology and semiotics at the University of Toronto, in an interview with Mashable says:
"The X has always been a Christian symbol, and it is the first Greek letter in the name of 'Christ,' Danesi says. "As far as I can tell, official letters in the medieval period and even after were literally sealed with the X — sealed with a kiss of faith, I guess."
Danesi also explains that illiterate people used the X to sign documents. It was customary for them to plant a physical kiss on the X.
From Washington Post:
The x became the signature of choice in the Middle Ages, a time when few people could write, and documents were sealed with an x embossed in wax or lead. At the same time, letters and books, as well as oaths of political and economic fealty between kings and their vassals, were “sealed with a kiss” — an early antecedent of the acronym SWAK, which became popular during World War I for soldiers to imprint on their letters home.
Also from Mash the Dish:
For Christians, Christ—and his symbol X—evoke faith and fidelity, and apparently medieval Christians, few of whom were literate, used X to sign documents as a token of their veracity
This custom would also appear related to the modern use of X as a signature or in checkboxes, though we should never underestimate that this practice could just be because X is a distinctive and easy-to-form shape to make. Consider how we have X marks spots, dating to at least the early 1800s, which would seem to originate simply from, well, X marking spots.