Section 377, which the LGBTQI community in India has been fighting against was introduced into the Indian law during British times. So a close look at the history of mental health and sexuality in the West is relevant to understand the arguments used to marginalise non-heteronormative sexualities in India. Here is an abstract of a document published by the Psychology Department of the University of California, Davis which gives a history of how homosexuality was perceived in Europe and America in the 18th, 19th, 20th centuries:
Modern attitudes toward homosexuality have religious, legal, and medical underpinnings. Before the High Middle Ages, homosexual acts appear to have been tolerated or ignored by the Christian church throughout Europe. Beginning in the latter twelfth century, however, hostility toward homosexuality began to take root, and eventually spread throughout European religious and secular institutions. Condemnation of homosexual acts (and other nonprocreative sexual behavior) as “unnatural,” which received official expression in the writings of Thomas Aquinas and others, became widespread and has continued through the present day (Boswell, 1980). [Bibliographic references are on a different web page]
Religious teachings soon were incorporated into legal sanctions. Many of the early American colonies, for example, enacted stiff criminal penalties for sodomy, an umbrella term that encompassed a wide variety of sexual acts that were nonprocreative (including homosexual behavior), occurred outside of marriage (e.g., sex between a man and woman who were not married), or violated traditions (e.g., sex between husband and wife with the woman on top). The statutes often described such conduct only in Latin or with oblique phrases such as “wickedness not to be named”). In some places, such as the New Haven colony, male and female homosexual acts were punishable by death (e.g., Katz, 1976).
By the end of the 19th century, medicine and psychiatry were effectively competing with religion and the law for jurisdiction over sexuality. As a consequence, discourse about homosexuality expanded from the realms of sin and crime to include that of pathology. This historical shift was generally considered progressive because a sick person was less blameful than a sinner or criminal (e.g., Chauncey, 1982/1983; D’Emilio & Freedman, 1988; Duberman, Vicinus, & Chauncey, 1989).
Even within medicine and psychiatry, however, homosexuality was not universally viewed as a pathology. Richard von Krafft-Ebing described it as a degenerative sickness in his Psychopathia Sexualis, but Sigmund Freud and Havelock Ellis both adopted more accepting stances. Early in the twentieth century, Ellis (1901) argued that homosexuality was inborn and therefore not immoral, that it was not a disease, and that many homosexuals made outstanding contributions to society (Robinson, 1976).