An Englishman, an Irishman and a Scotsman

"An Englishman, an Irishman and a Scotsman" is the opening line of a category of joke cycle popular in Ireland and the United Kingdom. The nationalities involved may vary, though they are usually restricted to those within Ireland and the UK, and the number of people involved is usually three or sometimes four. In Ireland, the characters are sometimes called "Paddy Irishman, Paddy Englishman, and Paddy Scotsman".  Depending on who is telling the joke, one nationality fares well and the other nationalities fare poorly according to national stereotypes.  For example, in England the punchline is usually based around the Irishman being stupid, the Scotsman being mean or miserly, and the Englishman being posh (or a snob but ultimately not the butt of the joke), whereas in Scotland and Ireland, the Englishman will typically be the butt of the joke. Sometimes, when the joke requires four people, a Welshman is brought in.

Form
The joke typically starts with the home or favoured nationality and ends with the nationality and associated stereotype against which the joke is made.  For example, in England, the joke begins "An Englishman, an Irishman and a Scotsman..." whereas in Ireland it begins "Paddy Irishman, Paddy Englishman, and Paddy Scotsman".

The joke typically places the three characters in a scenario.  How each person in the joke reacts to the scenario is then explained in order by person, the final reaction being the punch line, playing up to the stereotype of that nationality. The joke uses the rule of three, the first two characters being used to set up an expectation which is then subverted in some way by the third.

National variations
The "three nationalities" joke format is also very common in other countries. In these cases, the two foreigners are almost always portrayed as cocky, stupid, or naïve, while the home national is smart, practical, or in any case ultimately victorious.

Such jokes in Canada usually substitute the Irishman with a Newfie (a pejorative term for someone who is from Newfoundland)
in Turkey, as "An Englishman, a Frenchman, and Temel..." (the last being a fictional character from the Black Sea region) 
 "A Chinese, an American and a Japanese..."
in Poland, as "A Pole, a German and a Russian..."
in the Czech Republic, as "A Czech, an American and a Russian..."
in Russia, see Russian jokes: Russians
in Scandinavia, as "A Swede, a Dane and a Norwegian..."
in Sweden, the Bellman joke has this format: "a Russian, a German and Bellman...", where Bellman was originally a real person, Carl Michael Bellman
in Finland, as "A Finn, a Swede and a Norwegian (or Dane)..."
in Spain, as "a Frenchman, an Englishman and a Spaniard"
sometimes other national stereotypes are used: womanizing Italians, punctual Germans and so on. Sometimes nationals in specific professions are substituted: the Spanish Guardia Civil contrasted to the Italian carabinieri, French gendarmerie and English bobbies
 alternatively, Spanish regional identities may be substituted: funny Andalusians, mean Catalans, backwoodsy Basques, Galicians or Aragonese, cocky Madridians and so on. In contrast, the neighbouring Portuguese are seldom mentioned
 sometimes the Spaniard is the butt of the joke
in Italy, as "A Frenchman, a German (or an Englishman) and an Italian..." where normally the other foreigners are portrayed as slow or stupid and the Italian as smarter or winning by cheating
in Portugal, as "a Portuguese man, a Frenchman and an Englishman..."
in Germany, with varying other nationalities, but most commonly "a German, an Austrian and a Swiss..."
in Greece, many variants:
with stereotypical nationals (such as "a Greek, a Frenchman, and a German... ")
regional variations (such as "a Cretan, a Cypriot, and a Pontian..."). Here, Pontians are always the punchline of the joke, being portrayed as stupid and thus taking on a role similar to that of the Irishman in the UK variant.
in India, as "a Sardarji, a Bihari and a Bengali..."
in the countries of the former Yugoslavia, any variation on its many nationalities can take part (e.g. "a Croat, a Serb and a Bosnian..." or "a Montenegrin, a Macedonian, and a Slovenian..."
in New Zealand, as “an Englishman, an Irishman and a Māori man ...”, though sometimes the Irishman is replaced with a Chinese man depending on the context of the joke. The Maori man is usually the butt of the joke.
in Bulgaria, the usual form is "an American/Englishman, a Frenchman and a Bulgarian/Bay Ganyo...", though various other national stereotypes can be employed as well
in Brazil, there are variations. It is common to use an Argentinian or a Portuguese as the stupid one, if there is only one flawed man, with the nationalities of neutral characters being American, English or French. A shorter variation has only two men, usually a Brazilian and an Argentinian.
in Colombia, the Irishman is substituted with a Pastuso, despite some jokes contain a plot twist and this character is depicted as smarter.
regional stereotypes are included, depicting boastful (Paisas), lazy (Costeños or Opitas), phlegmatic (Rolos) or naive (Boyacenses) characters.
in Iran as "A Persian, a Turk and an Arab..."
in Chile as "a Chilean, a Peruvian and an Argentinian", with the Peruvian being the butt of the joke. Although it's also common for the joke to involve a Bolivian instead of an Argentinian.

The joke need not necessarily involve nationalities. Jokes about the hard sciences may begin "A mathematician, a physicist and an engineer..."

See also
Bar joke
Ethnic joke

References

Joke cycles
Ethnic jokes
British humour
Stock characters in jokes
Cultural depictions of British people
Cultural depictions of Scottish people
Cultural depictions of Irish people