The term eunuch () generally refers to a man who had been castrated to serve a specific social function.
The earliest records for intentional castration to produce eunuchs are from the Sumerian city of Lagash in the 21st century BC. Over the millennia since, they have performed a wide variety of functions in many different cultures: courtiers or equivalent domestics, treble singers, religious specialists, soldiers, royal guards, government officials, and guardians of women or harem servants.
Eunuchs would usually be servants or slaves who had been castrated to make them reliable servants of a royal court where physical access to the ruler could wield great influence. Seemingly lowly domestic functions—such as making the ruler's bed, bathing him, cutting his hair, carrying him in his litter, or even relaying messages—could in theory give a eunuch "the ruler's ear" and impart de facto power on the formally humble but trusted servant. Similar instances are reflected in the humble origins and etymology of many high offices.
Eunuchs supposedly did not generally have loyalties to the military, the aristocracy, or to a family of their own (having neither offspring nor in-laws, at the very least), and were thus seen as more trustworthy and less interested in establishing a private 'dynasty'. Because their condition usually lowered their social status, they could also be easily replaced or killed without repercussion. In cultures that had both harems and eunuchs, eunuchs were sometimes used as harem servants (compare the female odalisque) or seraglio guards.