First, homosexuality was serious at that time;
Second, it is harmful to the stability and development of human society.
China's ban on homosexuality probably originated from China's earliest philosophy of "one yin and one yang is the Tao". Secondly, it is the sexual concept of Confucian philosophy.
But judging from China's classics, there is no record of large-scale cruel persecution of homosexuality. In the feudal dynasty, this kind of thing was an elegant thing in the elite.
Many western religions are against homosexuality, especially Judaism, Christianity and Islam. All three monotheistic religions are against homosexuality.
Islam clearly stipulates that homosexuality is a big crime and should be punished as adultery outside marriage.