Before 1935, Hollywood and the films that it produced were pretty raunchy and did not shy from some the grittier aspects of life (racism, references to sex, stereotypical depictions of gay men, drinking, drug use, etc) and several off-screen scandals sent the studios to seek someone to rehabilitate Hollywood's image, eventually picking the rat-faced Presbyterian elder Will H. Hays in 1922. His Code was rarely taken seriously by directors and actors, but when the Catholic Church and religious zealots in general threatened massive boycotts in the early 1930s, filmmakers were forced to play by the rules, despite their resentment of this censorship and of Hays and Joseph Breen, the all-powerful head of the Production Code.
It would not be until 1968 that the Hays Code, which was by then undermined by television and terribly weak, was abandoned in favor of the MPAA rating system.
"Sexual perversion" (which lumped the LGBT community and actual perverts together)
Sexual slavery or prostitution
Miscegenation (keeping with the racism of the time)
Seduction (wenchers seducing ingenues, temptresses seducing the boy next door, seduction of any kind)
Nudity (no scenes of childbirth, sexual hygiene, nothing)
no portrayal of political, legal, or religious figures as villains or buffoons; no sympathy afforded to criminals, regardless of circumstances; no explicit violence (crime, operations, or cruelty); no ethnic jokes or religious jokes; no depictions of sexuality, and especially if it's not a heterosexual married couple; no drug related material; no cursing or foul language... everything had to be squeaky-clean and family-friendly, where heroes always win and goodness conquers all, generally ignoring the complications of reality.
Gays and lesbians were portrayed as unflatteringly stereotypeed as bulldyke lotharios and asexual sissies before the Hays Code; after the Code, they were harder to find and usually made an appearance as cold-blooded villains or self-loathing wretches.