I've read that a possible explanation is that an “X” is a stylized representation of two mouths kissing, while the “O” represents two pairs of arms coming together to complete a hug, but also have heard that many people in the Middle Ages could not read or write and would sign important documents with an “X," which was both a simple mark to make and a reference to the Christian cross.
Is there any validity to this?
According to "The Science of Kissing: What Our Lips Are Telling Us" By Sheril Kirshenbaum,
It was also during the Middle Ages that a businesslike kiss was employed as a legal way to seal contracts and business agreements. Many men did not know how to read and write, so they would draw an "X" on the line and kiss it to make it legal. This carried over into the way we write "X" today to symbolize a kiss, as well as the expression "sealed with a kiss." The kiss between a bride and groom was also viewed as marking a kind of legal business agreement, crystallizing all the responsibilities marriage entailed.
According to Google's Ngram, the first appearance of "XOXO" seems to be 1855. Interestingly, "XO" goes back further, but I really question how accurate that is, because one book filled with "XO" is this one. Take a gander and see if you notice a problem. :)
I can't find any reliable sources on the origin of the O. I did read one compelling argument that it derives from "noughts and crosses," or tic-tac-toe. As a linguist, I find that transition plausible, that is, knowing X represents kisses and associating that with O based on noughts and crosses. Additionally, "noughts and crosses" does appear in print in 1841, which is plenty of time for it to permeate the public mind and associate X and O together. (Note that both "noughts and crosses" and "XOXO" probably appear before 1841 and 1855, respectively, this is just a latest date for which they appear. It's also worth noting this is only a rough estimate at best due to the limitations of Ngram, but it is still sufficient for our purposes for now.)
While we're at it, is it known how "88" came to mean "Love and Kisses" in morsecode?