In medieval times, most people were unable to read or write. When it
came time to sign a document, people who could not write usually made
an "X" mark. Of course, an "X" is not much of a signature. To add a
sense of commitment, it became customary to kiss the "X" after
writing it.
Kissing the "X" was "performance law," a ritual act that bound the
parties the way legal documents bind us today. This act, witnessed
by the person who wrote the text, represented a solemn guarantee of
the truthfulness of what was written, and an oath to carry out
whatever obligations were stated in the document.
Over the years, the "X" and the kiss became interchangeable. Today,
people who can read and write might still add one or more "X" marks to
their letters, maybe with a couple of "O"s thrown in for hugs.