To understand the difference, one must consider the historical contexts when the terms come into being.
Generally, the term kingdom is used when the inhabitants were largely homogenous in ethnicity, language or culture, and also share much common heritage. Certain kingdoms contain pockets of regional minorities, and there is a tendency for these minorities to be assimilated by the dominant ethnic group.
Examples: Historical kingdoms of England, Scotland, Wales, Ireland, France, Italy, Greece, Denmark, Sweden etc.
The term empire is used when the inhabitants were heterogenous in ethnicity, language or culture, and had been merged from previously separate states with distintively different people. Though the empire is formed by a dominant ethnic group, the sheer vastness of the empire and diversity meant that the heterogenous demography would remain.
Examples: Historical Roman Empire, Byzantine Empire, Holy Roman Empire, Russian Empire. Napoleon could only be called an emperor properly when he conquered non-French territories.
The term 'emperor' is also applicable to a king who conquered other sizable kingdoms.
Historical background (Europe)
In Europe, the term 'emperor' originated with the ancient Romans.
The Romans found themselves overlords of a diverse group of people, from Celts and Greeks in Europe to Egyptians in Africa to Arabs and Jews and Pheonicians in the Middle East. There was no way everyone would take up Latin and drop their own culture.
Historical background (China)
In China, prior to the Spring Autumn and Warring States period, regional languages existed. The Empire was formed when the State of Qin conquered all other states, ruling a territory many times larger than any kingdoms China had ever known.
Through strong institutional measures, assimilation was carried out successfully in China.