The original idea of the opera came from Jonathan Swift, who wrote to Alexander Pope on 30 August 1716 asking "...what think you, of a Newgate pastoral among the thieves and whores there?" Their friend, Gay, decided that it would be a satire rather than a pastoral opera. For his original production in 1728, Gay intended all the songs to be sung without any accompaniment, adding to the shocking and gritty atmosphere of his conception. However, a week or so before the opening night, John Rich, the theatre director, insisted on having Johann Christoph Pepusch, a composer associated with his theatre, write a formal French overture (based on two of the songs in the opera, including a fugue based on Lucy's 3rd act song "I'm Like A Skiff on the Ocean Toss'd") and also to arrange the 69 songs. Although there is no external evidence of who the arranger was, inspection of the original 1729 score, formally published by Dover Books, demonstrates that Pepusch was the arranger.
The work took satiric aim at the passionate interest of the upper classes in Italian opera, and simultaneously set out to lampoon the notable Whig statesman Robert Walpole, and politicians in general, as well as the notorious criminals Jonathan Wild and Jack Sheppard. It also deals with social inequity on a broad scale, primarily through the comparison of low-class thieves and whores with their aristocratic and bourgeois "betters."
Gay used Scottish folk melodies mostly taken from the poet Allan Ramsay's hugely popular collection The Gentle Shepherd (1725) plus two French tunes (including the carol 'Bergers, Ecoutez La Musique!' for his song 'Fill Every Glass'), to serve his hilariously pointed and irreverent texts. Pepusch composed an overture and arranged all the tunes shortly before the opening night at Lincoln's Inn Fields on 28 January 1728. However, all that remains of Pepusch's score are the overture (with complete instrumentation) and the melodies of the songs with unfigured basses. Various reconstructions have been attempted, and a 1990 reconstruction of the score by American composer Jonathan Dobin has been used in a number of modern productions.
Gay uses the operatic norm of three acts (as opposed to the standard in spoken drama of the time of five acts), and tightly controls the dialogue and plot so that there are surprises in each of the forty-five fast-paced scenes and 69 short songs. The success of the opera was accompanied by a public desire for keepsakes and mementos, ranging from images of Polly on fans and clothing, playing cards and fire-screens, broadsides featuring all the characters, and the rapidly published musical score of the opera.
The play is sometimes seen to be a reactionary call for libertarian values in response to the growing power of the conservative Whig party. It may also have been influenced by the then-popular ideology of Locke that men should be allowed their natural liberties; these democratic strains of thought influenced the populist movements of the time, of which The Beggar's Opera was a part.
The character of Macheath has been considered by critics as both a hero and an anti-hero. Harold Gene Moss, arguing that Macheath is a noble character, has written, "[one] whose drives are toward love and the vital passions, Macheath becomes an almost Christ-like victim of the decadence surrounding him." Contrarily, John Richardson in the peer-reviewed journal Eighteenth-Century Life has argued that Macheath is powerful as a literary figure precisely because he stands against any interpretation, "against expectation and illusion." He is thought to be modelled on the notorious highwayman James Maclaine.
The Beggar's Opera has had an influence on all later British stage comedies, especially on nineteenth century British comic opera and the modern musical.