From the pre-Qin period to the late Qing Dynasty, the eunuch system lasted for thousands of years. Why did rulers of all dynasties set up eunuchs?
Fan Ye answered this question in "Book of the Later Han Dynasty: Biography of the Eunuchs". He said: "The Book of Changes says: 'The sky hangs on the image, and the sage will take it.' The eunuch has four stars, which are on the side of the throne, so the number of officials in the Zhou Li is also prepared." The meaning of this sentence is that the eunuch is the result of the sage taking the image from the sky. The answer to
is obviously incorrect. There is no necessary connection between the signs in heaven and the bureaucracy in the world. To explore the reasons for the emergence of the eunuch system, we must find the answer from the ancient economic and political relationship.
In ancient times, the monarch was the largest land owner. As the saying goes, "All under the world is the king's land, and all the king's ministers are the king's ministers." The monarch's possession of land and subjects determines his extreme luxury in life and his political autocracy and dictatorship.
In life, the monarch can save wives and concubines and be lewd. While serving the monarch, these women in the harem needed many people to serve them. In the eyes of the monarch, the slave who serves his women cannot be a man. After all, in ancient times, the phenomenon of a monarch's wife having an affair with her ministers, a monarch's wife having an affair with her sons, a monarch's son having an affair with her mother, and a servant having an affair with her palace maids was very common. The monarch does not want lust other than himself to exist, nor does anyone allow him to get involved in his harem.

In addition, ancient China was a patriarchal country. The world is the world of the monarch and the world of one surname. A huge country needs someone to inherit it. Most of this successor are the sons of the monarch's pure blood relationship. If blood ties are chaotic, the change of royal power will not be stable and society will be turbulent. This is not only what the monarch does not want to see, but also what the ministers do not want to see. Therefore, there are no men other than monarchs in the palace.
However, we must also see that the palace is a complex world. Internal service includes sweeping, handling, diet, public security, etc.; field service includes procurement, attendants, orders, etc. These things are not something that the maid can do.
In this case, only eunuchs are suitable for serving in the palace.
From a political perspective, eunuchs are generally born in poverty, and some are even orphans. They entered the palace since childhood and had no complicated relationships in society. They were not easy to collude with hostile forces, nor could they become monarchs. In other words, there is no conflict of interests between eunuchs and monarchs, so you can use them with confidence.
From a physiological point of view, eunuchs are neither male nor female, and they cannot have sex, and they can just wait for concubines in the harem. They are healthy and can engage in strong labor or go outside the palace to do business, making up for the innate deficiencies of the palace maids.
Since there are so many "benefits" for using eunuchs, the monarch will naturally enjoy it, and the eunuch system is thus established.
Having written this, the question is, where did the eunuchs needed by the palace, such as the number of sands in the Ganges River, come from?
It is necessary to note that eunuchs are not necessarily the ones who cut off their male roots. There are a very small number of eunuchs, Shi Tianshi, who are congenital dysplasia. For example, Zhao Gao, the eunuch of the Qin Dynasty, was a eunuch. He was born in the Hidden Palace and had sexual dysfunction.

In addition to the eunuchs, there are four main sources of eunuchs:
One, self-castration. Self-guidance is self-guided, and it is not caused by punishment. At the latest, there was a situation of self-conception in the Han Dynasty. "Book of the Later Han Dynasty: Biography of Liu Yu" records: "Poverty people may sell their heads to reward them, and their fathers and brothers will be disabled, and their wives will be divided when they meet each other." Historians believe that "fathers and brothers will be disabled" means self-cultivation.
The second is the sinner. In ancient times, it was not just one person who committed crimes, but sometimes it involved the whole family and even nine tribes. During the reign of Emperor Wu of Han, Zhang Anshi's brother was a guest of Prince Wei. He was implicated because of the prince's crime. Zhang Anshi wrote a letter to him and Emperor Wu of Han castrated him in anger. There is also Sima Qian, who was also taken down from the silkworm chamber by Emperor Wu of Han because he said a few words to Li Ling.
The third one, prisoners of war. This situation mainly occurs during periods of court change or social turmoil.For example, during the Qin Dynasty's war to unify the six kingdoms, a large number of prisoners of war were arrested every year, so castration was carried out. For example, the Tuoba nobles of the Northern Wei Dynasty were also used to castrating young prisoners of war during the war.
The fourth is tribute. This situation is more prominent in the Tang and Ming dynasties. The territory of the feudal empire continued to expand and frequent exchanges with the surrounding areas. In order to please the central government, remote areas and vassal states pay tribute to local specialties and rare foreign objects every year, and eunuchs are also one of the tributes. For example, Fujian, Lingnan, Annan and Goryeo often send young castrated children to the capital.