The key lyric in the song is "the rain in Spain stays mainly in the plain", which contains five words that a Cockney would pronounce with [æɪ] or [aɪ][1] – more like "eye" [aɪ] than the Received Pronunciation diphthong [eɪ].
With the three of them nearly exhausted, Eliza finally "gets it", and recites the sentence with all "proper" long-As.
The trio breaks into song, repeating this key phrase as well as singing other exercises correctly, such as "In Hertford, Hereford, and Hampshire, hurricanes hardly ever happen", which Eliza had failed before by H-dropping.
According to The Disciple and His Devil, the biography of Gabriel Pascal by his wife Valerie, it was he who introduced the famous phonetic exercises "The rain in Spain stays mainly in the plain" and "In Hertford, Hereford, and Hampshire, hurricanes hardly ever happen" into the script of the film, both of which were later used in the song in My Fair Lady.
[2] Versions of "The rain in Spain stays mainly in the plain" in various languages include: In 2012, a punk rock version of "The Rain in Spain" was performed in the comedy-musical TV series Glee, episode "Choke", by Mark Salling (as his character Puck) with his fictional glee club, New Directions.