Shakespeare wrote iambic pentameter because that was the most common verse meter of the time. He didn't establish it. Edmund Spenser used it in The Faerie Queene:
Lo I the man, whose Muse whilome did maske,
As time her taught, in lowly Shepheards weeds,
Am now enforst a far unfitter taske,
For trumpets sterne to chaunge mine Oaten reeds,
And sing of Knights and Ladies° gentle deeds;
And Christopher Marlowe in Dido Queen of Carthage:
Iup. Come gentle Ganimed and play with me,
I loue thee well, say Iuno what she will.
Poets had been using it since at least Middle English, such as Geoffrey Chaucer in Canterbury Tales:
Whan that aprill with his shoures soote
The droghte of march hath perced to the roote,
And bathed every veyne in swich licour
Of which vertu engendred is the flour;
(The first couple of lines are somewhat loose in the meter, but the second couplet is fairly rigorous, roughly pronounced: and BAH-thed EV'ry VEIN in SWICH li-QUOR/of WHICH vir-TUE en-GEN-dred is the FLOOR [flower]".)
The "why" is simply that it's perceived to fit the natural rhythms of English fairly well. French and Italian frequently use six-foot lines, which correspond to about the same number of words but with more gender-marked endings. English words tend to mix stressed and unstressed syllables, so you get iambs and trochees in speech quite frequently. I don't really know why we picked iambic rather than trochaic verse; for all I know it's arbitrary.
As for why he wrote in verse at all... partly it makes plays easier to memorize. Some kind of structure helps you remember how the words fit together: one sound cues the next. Songs are even more memorable, but blank verse seems to be sufficiently memorable for actors to keep multiple plays going in repertory.
And finally, it just sounds good. Audiences like the sound of verse, going back to antiquity. It can have a hypnotic quality.
Iambic pentameter seems to fit a sweet spot in English of having enough structure to be memorable and enjoyable, without feeling sing-songy. Different languages settled on different forms to meet the common sounds available in those languages.
Shakespeare wrote almost exclusively in verse for his early plays, and got more prosey as he went on, especially for comic characters. Verse carries the power of drama especially well. As he got more comfortable with letting the wordplay alone carry the comedy, he began to write more prose.