As an English verb, kowtow meant grovelling before it meant kneeling. The figurative verb is recorded in 1826, more than twenty years before the literal one.
The word is Chinese. Etymonline gives the older romanization k'o-t'ou, from k'o, "knock, bump," and t'ou, "head." Merriam-Webster gives the modern pinyin form kòutóu, from kòu, "to knock," and tóu, "head." Either way the literal sense is "knock the head": kneeling and touching the forehead to the ground in homage.
Before the emperor this was not a casual bow. Britannica says that by the Ming period it involved "three kneelings and nine prostrations." For foreign envoys, performing it signified their country's acknowledgement of the emperor as the "son of heaven."
That is where Britain ran into trouble. In 1793 George Macartney led the first British diplomatic mission to China, to the Qianlong emperor. He refused to kowtow and went down on only one knee, as he would before his own king. The emperor rejected all of the mission's requests.
A second British embassy under Lord Amherst arrived in 1816, and historians have blamed its failure on advice not to kowtow. Amherst never appeared before the Jiaqing emperor, and his party was expelled from Peking on the day it arrived.
English picked up the word in the middle of these encounters. The noun is recorded from 1804, for the custom of touching the ground with the forehead while kneeling. By 1826 the verb meant to act obsequiously, and the literal verb sense is not recorded until 1848. One plausible reading of that order: British readers met the kowtow as something their diplomats refused to do, so the word arrived already loaded with humiliating deference.
Today almost nobody uses kowtow for a physical bow. It describes giving in too easily to the boss, a donor or a foreign government, and the forehead stays off the floor.