All languages have inherent rhythms that result from the interplay of stressed and unstressed syllables and the contrast between long and short vowel sounds. In English, those rhythms are most often analyzed in the context of verse, where the rhythm of the language manifests itself in formal patterns that can be categorized along two different lines.
The first of these categories is based on the pattern of stressed and unstressed syllables in each line, with the groupings of syllables referred to as "feet." Each foot conforms to a pattern, whether stressed followed by unstressed, unstressed followed by stressed, or two equally stressed syllables. The term "iambic" refers to a particular type of foot, namely an unstressed syllable followed by a stressed syllable, as in the word "compare."
The notion of iambic meter originated in classical Greek and Latin poetry, where the meter is defined by the alteration of long and short syllables. That framework was adapted to English verse and the long and short syllables of classical meter were replaced by stressed and unstressed syllables respectively.
In addition to a pattern of stressed and unstressed syllables, lines of verse have specific lengths. Those lengths are expressed as the number of pairs of syllables, or feet, in a line. Lines with five feet are written in "pentameter."
Iambic pentameter, then, refers to a line that has five pairs of syllables, where each pair is an iamb and consists of a stressed syllable followed by an unstressed syllable. Those syllables do not have to be paired within a word, but can be made up of two words since the natural inflection of the English language can still define an iambic rhythm.
For example, Shakespeare used iambic pentameter throughout his work, as in this excerpt from Sonnet XVIII:
Shall I compare thee to a summer's day?
Thou art more lovely and more temperate:
Rough winds do shake the darling buds of May,
And summer's lease hath all too short a date:
Those well known lines fall naturally into the iambic meter. Iambic pentameter does not have to be part of verse that rhymes. It serves equally well in blank verse, which is characterized by having a rhythmic meter without rhyme, as in Robert Frost's "Birches."
When I see birches bend to left and right
Across the line of straighter darker trees,
I like to think some boy's been swinging them.
But swinging doesn't bend them down to stay.
Although the structure of iambic pentameter is well defined, that does not mean that it cannot be varied or mixed with other schemes. Sometimes, the departure from the strict form contributes to the effect, as it does in "Birches." After those first four strictly iambic lines, Frost continues:
Ice-storms do that. Often you must have seen them
Loaded with ice a sunny winter morning
After a rain.
The break in the poem's formal scheme caused by the simple declaration that "ice storms do that" calls attention to that simple statement, whether the reader regards it as a dramatic effect or a simple, matter-of-fact aside by the poet.
In addition to allowing variations from the strict form, whether a particular line is written in iambic pentameter can often be open to interpretation. Take, for example, what is perhaps Shakespeare's most famous line from his most famous soliloquy, delivered by Hamlet:
To be, or not to be: that is the question.
Clearly, the speech opens in iambic pentameter, with stresses on the second, fourth and sixth words. The next two words, though, can be read in different ways, stressing either "that" or "is" according to the reader's preference. The traditional and more popular approach seems to put the emphasis on "that" and thus departs from iambic meter. An emphasis on "is" retains the iamb. It is impossible, of course, to call one reading correct and the other incorrect. It is at least clear that the alternative readings create different effects and that those effects are enhanced by the way the words are treated in the rhythmic flow of the line.
That single famous line demonstrates another variation, as it contains eleven syllables. That departure from the form is a relatively common one among the variations, with lines ending in a last, unstressed syllable, known as a feminine ending.
Iambic pentameter is generally agreed to have become the dominant form for poetry in English after Chaucer, although even Chaucer may have written more in iambic pentameter than is immediately obvious to later readers. Changes in pronunciation after his death in 1400 have rendered a final "e" at the end of a word silent, and there is at least a case to be made that Chaucer intended those letters to be pronounced.
As to the reasons for the dominance of iambic pentameter, comparisons are often made to its chief competitor "tetrameter," which consists of eight-syllable, four beat lines, iambic or otherwise. Tetrameter is the form we know from nursery rhymes and marching cadences, and it imposes a very regular rhythm that may itself be a limitation. Iambic pentameter provides a less rigid and more natural flow that may better approximate natural English speech. This is not to say that English is naturally spoken in iambic pentameter, but it may be that the form is able to smoothly accommodate the pace and intonation of the language while allowing the underlying metrical form to be clearly heard.