'Section 377A of the Penal Code of Singapore is the main remaining piece of legislation which criminalises sex between mutually consenting adult men.
Section 377A ("Outrages on decency") states that:
Any male person who, in public or private, commits, or abets the commission of, or procures or attempts to procure the commission by any male person of, any act of gross indecency with another male person, shall be punished with imprisonment for a term which may extend to 2 years.
To understand Section 377A, the enactment of its mother statute, Section 377, must first be explained. Section 377 criminalised sex "against the order of nature".
Whoever voluntarily has carnal intercourse against the order of nature with any man, woman or animals, shall be punished with imprisonment for life, or with imprisonment for a term which may extend to 10 years, and shall also be liable to fine.
Explanation. Penetration is sufficient to constitute the carnal intercourse necessary to the offence described in this section.
An analysis of the origin of British laws that sought to prohibit buggery and their evolution into Section 377 is found in an academic paper entitled 377 and the Unnatural Afterlife of British Colonialism in Asia by Professor Douglas E. Sanders at Thailand's Chulalongkorn University.
In summary, the British anti-buggery law was enacted in 1534, taking over from ecclesiastical law. The wording used, which included "abominable" (taken from the book of Leviticus in the Old Testament), "buggery" (which, by the 13th century, had become associated with sodomy), and "vice", confirms its religious character. It was formulated in the context of King Henry VIII's break from papal authority to establish the Anglican church. Its purpose was to justify the seizure of Catholic monasteries and the confiscation of their other wealthy properties. The pretext was the alleged sexual immorality of those in the religious vocation. Without this anti-Catholic agenda, it seems unlikely that it would have been enacted.
Codification of law, particularly criminal law, became a major reform project in Britain in the 19th century, pushed by Jeremy Bentham and the utilitarians. Codes were well-suited to British colonialism, providing a single, orderly written version of areas of law - easy to enact for a colony.