The Apartment was made in 1960, as the film industry was shifting away from major studio contracts towards corporate distribution of independently-produced films. As a film about shifting sexual mores and the alienation of the workplace in midcentury America, the film stands at the cusp between the 1950s and the 1960s, a time of great change in American film and American culture. Director Billy Wilder had already directed Some Like it Hot the year before, a film that flirted with looser and franker depictions of sexuality, gender, and infidelity in film. Given the success of that film, he was emboldened to make The Apartment, which was considered controversial at the time and now stands as an early and genre-defining sex comedy.
By the 1950s, the Motion Picture Production Code—a strict set of guidelines that filmmakers had to follow in order to censor certain material deemed inappropriate for film—was still technically in effect, but its influence was dwindling. With the invention of the television, people started watching things in the privacy of their homes, which meant that film studios needed to find ways to motivate people to leave the house and go to the theater. Additionally, foreign films (which were not censored by the Production Code) were gaining popularity with American audiences. After a court case surrounding a Roberto Rossellini film, The Miracle, the standards for decency in film began to shift. By the late 1950s, racier films had begun to appear, such as Anatomy of Murder, Psycho, and indeed, Billy Wilder's Some Like It Hot.
At the time of its release, Some Like it Hot did not officially meet the standards of the code. It depicted crossdressing, infidelity, and explicitly alluded to sex as well as homosexuality. When the film was a huge success at the box office, however, it became clear that audiences did not care. Film critics credit the success of Some Like it Hot with diminishing the influence of the Motion Picture Production Code. Because of his role in legitimizing racier themes in film, Wilder was confident that he could score a success with The Apartment, even though its plot orbited around extramarital affairs and suicide. While the Production Code remained in effect throughout the 1960s, its influence had certainly weakened, and by 1968 it was abandoned in favor of MPAA film rating system.