In 1959, on hearing that Billy Wilder was making a comedy that started with a machine-gun massacre, the producer David O Selznick warned: "They're going to walk out in droves!" The first test screening seemed to prove him right – the middle-aged, small-town audience stayed silent; some shuffled in their seats and some, indeed, walked out.
One person laughed, once. Some Like It Hot nearly died there. At Wilder's insistence, they tried again, playing the film to a largely student crowd in a college town. They loved it. And most who see it have loved it ever since.
Yet it was unsurprising that the first audience was thrown. The cross-dressing at the heart of the film offered the wrong kind of daydream. What's more, its early scenes bring in something genuinely grim; it's startling when a comedy includes the machine-gunning of a man pleading for his life. There is, indeed, a streak of darkness in it, from the killings to the story of the girl who slashed her wrists when Valentino died. (There are suicide attempts in many of Wilder's films, from Sunset Boulevard to The Apartment.) Yet the girl provides the keynote to the film's love affair with fantasy.
Some Like It Hot begins as a strange pastiche, more Scarface than Sabrina, with George Raft (as "Spats" Colombo) reprising his 1930s roles as a hard-boiled gangster. By accident, two burlesque musicians, Joe (Tony Curtis) and Jerry (Jack Lemmon) witness Colombo's Valentine's Day massacre of his rival's gang. Desperate to avoid being the mobster's next victims, they run off, drag up and join an all-girl band, Sweet Sue and Her Society Syncopators, headed for three weeks in Miami Beach.Joe becomes Josephine, and Jerry transforms into Daphne. In disguise, Joe falls for the band's singer, Sugar Kowalczyk, AKA "Sugar Kane", played by Marilyn Monroe. Once in Florida, Sugar intends to marry rich, and, aided by some slumber-party revelations, Joe decides to disguise himself as just the right kind of millionaire for her, the gentle, bespectacled son and heir of Shell Oil – "Junior".
In the film it is suggested that you may prefer things classical or like them hot; Wilder's film achieves both. A comedy of errors and cross-dressing, it is closer to Plautus than to Judd Apatow: formally perfect, yet suffused with all Hollywood's vivid vulgarity. Watching such familiar classic films, you may feel the movie has become its own tribute act, the audience hitting the punchlines one beat ahead of the performers. But the greatest films – Some Like It Hot among them – smash their own icon; every time I see it, there's a freshness about it, a tautness that will not sag.
Wilder's films often leave us with the taste of a sugared cynicism. Yet Some Like It Hot radiates an exuberance: the characters party, run, race on bicycles, slap the bass (not pluck it), dance, throw balls, fall over, tango till dawn and, by sheer force of energy, escape. Its great symbol is the party that takes place in the train sleeping car, one that begins small and keeps growing, the narrow bed filled to overflowing with more and more women. Once it grabs hold of you, the laughter in the film doesn't let you go. There are a few islands of stillness in the mayhem, between Josephine and Sugar in the train's washroom, or between Junior and Sugar on the yacht. These pauses of intimacy give space to a love story that proceeds almost entirely through pretence.
By setting the film in 1929, the scriptwriters, Wilder and IAL Diamond, tease out the ironies of history. It is Gatsby's decade, an oasis of dreaming. Sugar Kane is on the hunt for millionaires, not realising that they are an endangered species, with the Wall Street crash only months away. A nostalgia suffuses the film, offering a backward glance to the world of Wilder's own youth. Back there, in the days before his flight from Europe to America, there's not yet been a Great Depression, an Anschluss, an Auschwitz.
American dreamers fascinated the downbeat, worldly wise, Viennese Billy Wilder. In his films, sceptics tend to succumb, won over or worn down by the power of dreaming – take Sunset Boulevard's Norma Desmond, sealed off in a dream of her silent-movie stardom, or Love in the Afternoon's would-be female Don Juan.
Some Like It Hot has its dreamers too, not least the gangsters – self-mythologisers caught up in a vision of themselves as immaculate killers. But the greatest dreamer of all is Monroe, though she is also a dream for others, an embodied reverie, apt for desire, available for imitation. In his next, even better, film, The Apartment, Wilder joked about it, having one of his seedy insurance workers pick up a "real Marilyn Monroe" in a bar. In Some Like It Hot, Monroe's iconic position as all‑American sufferer is in play; as she sings "I'm Through With Love", Sugar is despairing, but the shadowy hotel guests are dancing anyway, oblivious. Her persona contains a quality of beleaguered innocence, such that no one condemns her "gold-digging", the plan being too fanciful, too unworldly to look sinister.
On screen, she was unique yet generic – the quintessential blonde. In Wilder's The Seven Year Itch (1955), there are two dreamers, not just vole-faced Tom Ewell, but Monroe, "The Girl" herself (she never assumes the fixity of a name). In that film, she would seem a shadow of other people's desires, but is brimful with yearnings of her own – for elegance, for sophistication, for New York. She's a blond Holly Golightly in her first month in Manhattan.
In a sense, Monroe is Some Like It Hot's third female impersonator. She enacts beauty as advertised. You might not want to be her, to adopt so strong a version of what the world imagined men would like. Yet her palpably fragile impersonation of the fantasy woman itself could act as an exposure of the fantasy's essential unreality. For there was always something ostentatiously artificial about Monroe; in Howard Hawks's Monkey Business, Ginger Rogers threatens her: "I'll pull your blond hair out by its black roots!" Wilder wondered "whether Marilyn is a person at all or one of the greatest DuPont products ever invented". Often unnoticed on set, passed by on the street, Norma Jeane Mortenson could turn on being "Marilyn" and in an instant claim everyone's attention.
Playing an unregarded girl on the make, Monroe nevertheless fills the movie with the alluring shimmer of "the star". We all know that these actors are workers in "the dream factory". So it is that when Joe impersonates his anhedonic tycoon, he adopts Cary Grant's voice as disguise ("Nobody talks like that," protests Jerry): it's an entirely fitting mask, the man becoming the movie star all men wanted to be in order to woo the movie star that all men were supposed to adore. ("Everyone wants to be Cary Grant," complained Cary Grant. "Even I want to be Cary Grant.") And, meanwhile, Jerry becomes Marilyn, turning himself from a neurotic bull-fiddle player into a blond temptress.
All this playing with Hollywood's pipe dreams makes perfect sense in a film whose ultimate idea is that love is illusory. Wilder and Diamond explore the familiar thought that when we fall in love with someone, we really fall for an image of our own making. Osgood, the satchel-mouthed genuine millionaire, worships Daphne, who only exists as a performance; Sugar adores Junior, a figment of her own imagination impersonated by someone who has peeked backstage at her dreams. Finally, there's the audience too, smitten by the delectable shadows of the silver screen – just like that suicidal woman, unable to live on in a world without Valentino.
Cross-dressing brings in the same question about illusion, asking us if we desire the surface or the essence. For the joke to work, there has to be a good enough reason for them to don women's clothes. In the film Some Like It Hot is based on, the German Fanfaren der Liebe (1951), it's down to simple economic necessity. Wilder and Diamond felt something more desperate was needed, and so the gangsters had to come in. If film creates narrative from fragments and cuts, then the key cut in Some Like It Hot is the one that takes us from typical boys, Joe and Jerry, to the two of them teetering down the railway platform as high-heeled women. One of the jokes is that they are the band's most ladylike members. When he first puts on high-heels, Jerry staggers and stumbles, but by the film's end he is so used to them that he forgets he even has them on. With his pretty-boy looks, cross-dressing suited Curtis, whose first ever acting role had been playing a girl in am-dram.
I once met a student who refused to laugh at Some Like It Hot. His immunity to the film had a political basis: he viewed it as a sham act of subversion, an apparent exposure of the artifice of gender roles that, in the end, settles down to reinforce the status quo. Well, perhaps. Yet, for its time, Josephine's "lesbian" kiss with a startled Sugar was a daring gesture. Besides, what about the film's capacity for mayhem and wit? Wilder and Diamond celebrate the comic ability both to get into trouble and to get out of it, to defeat death, to make your escape. In the end, it endorses – as all Wilder's films do – a limited, but humane decency. And the film's last line – "Nobody's perfect" – offers a way out of the conundrums of gender politics, also providing an escape from the fear that desire itself is a delusion. When Osgood refuses to stop loving feisty young Daphne, even though she drinks, flirts and cannot have children – even though, finally, she is a man – the film shows us a real person lovable behind the facade. He doesn't love Daphne for her assumed womanliness, he loves her for something he has glimpsed in her – the Norma Jeane in the Marilyn, the unguessed at heart.
• Some Like It Hot has been digitally restored and is showing at the BFI, London SE1, until 21 August.
guardian.co.uk © Guardian News and Media Limited 2010