A common response is to just say "it's the British's fault" and be done with it, but that doesn't explain why it remained in place for so long. Hinudism (which is, admittedly, not just one thing) has scriptural references to homosexuality and ancient forms seem to have been very sex-positive.
Followup: The Zoroastrian composite "manual of conduct" known as the Videvdad or Vendidad has a number of verses along the lines of,
Vd 8.32: Ahura Mazda answered: 'The man that lies with mankind as man lies with womankind, or as woman lies with mankind, is the man that is a Daeva; this one is the man that is a worshipper of the Daevas, that is a male paramour of the Daevas, that is a female paramour of the Daevas, that is a wife to the Daeva; this is the man that is as bad as a Daeva, that is in his whole being a Daeva; this is the man that is a Daeva before he dies, and becomes one of the unseen Daevas after death: so is he, whether he has lain with mankind as mankind, or as womankind [i.e. whether he penetrates or is penetrated].'
ranging from Vd 8.26-32: http://www.avesta.org/vendidad/vd8sbe.htm (infamously, as you can see, Ahura Mazda opining on proper sexual intercourse is framed by, uh... discussions of funeral rites.) I don't off-hand know how old this material is (the Vd has material spanning an enormous range in time and this isn't easily datable); are there any similar commands in Vedic or other Sanskrit tradition?
While you're waiting for responses, you may be interested in the responses to a similar question I asked a month ago: India's Supreme Court is considering decriminalizing gay sex, in part because "it is argued to be at odds with precolonial India's acceptance of homosexuality." What was precolonial India's perspective of homosexuality?
The answers i gave to this question can put things in context. although i wrote that in the context of sexual violence most of those inferences do apply to your question too. Id say that response "the british did it" though an oversimplification is still partly credible. This is because colonialism was not just a process of military and political rule and economic extraction, it was also a social process that significantly changed the cultural practices, moral ethos and sexual behavior of the indian subcontinent. ive tried to encapsulate a description of lot of these social changes in the answer ive linked.