Section 377A was introduced to curb colonial-era male prostitution: Lawyers

There was also an issue of British civil servants soliciting their services.