What is the source or origin of the custom to kiss a Mezuzah?
It's mentioned in the Kitzur Shulchan Aruch
The Rama, however, mentions that one should just put his hand on the Mezuza. (As a side note, the Lubavitcher Rebbe used to put his hand on the Mezuza without kissing it).
The Rama brings a source from the Gemara in Avoda Zara where it relates that when Onkulus was being arrested and let out of the house, he put his hand on the Mezuza. When asked the meaning of the Mezuza, Onkeles answered that in contrast to a human king who is guarded by his servants, Hashem guards his servants.