It began getting seriously enforced by Joseph I. Breen who became the head of the committee for the code. It was a way to censor movies in Hollywood in order to ensure that they weren't spreading immoral ideas. It began even earlier but the thirties were a time when the code actually became a rule and it had to be obeyed.