Uranus has 27 known moons, which is impressive. They also share a feature that makes them unique in the Solar System. Although the moons of the other planets are named from mythology, the Uranian moons are named for characters from English literature, primarily Shakespeare. How did they get these names?
Naming a new planet
The first new planet ever discovered was Uranus. The other planets from Saturn inward are visible to the unaided eye, and have been known since prehistoric times. William Herschel discovered Uranus in 1781. Since it's twice as far from the Sun as Saturn, the diameter of the known Solar System was doubled.
But what to call the new planet? Planets were associated with gods in classical religions, so this is how they got their names. No individual had named a planet. Herschel named his planet Georgium Sidus (George's Star) for his patron King George III of England. The name was ignored outside England and people tended to call it Herschel. German astronomer Johann Bode suggested Uranus, in keeping with the classical tradition. Uranus was the sky god and father of Saturn. Although the name took a while to catch on, it was generally accepted by about 1850.
Moons - 2, 4, or 6?
William Herschel discovered two moons of Uranus about six years after he discovered the planet. They are now called Titania and Oberon. He reported seeing four more, but these appear to be viewing errors. (Uranus is very far away and moons are very small.) Herschel didn't name the moons.
Over half a century later English astronomer William Lassell observed Herschel's two moons and found two more. (Neither of Lassell's moons corresponded to any of those which Herschel had claimed.) Lassell numbered the moons from I-IV, starting with the one nearest to Uranus.
Saturn's moons - numbered and named
Way back in 1655 Dutch astronomer Christiaan Huygens discovered Titan. His telescope was primitive, but Titan is very big - larger than Mercury. Since he only saw one moon, Huygens referred to it as Saturni Luna (Saturn's moon). When other moons were discovered, they were numbered based on their distance from Saturn. It got messy when new moons were found between the orbits of previously discovered ones, so they all had to be renumbered.
John Herschel, William's son and an eminent scientist in his own right, found the numbering and renumbering of Saturn's moons confusing. For his own convenience he gave them names. Herschel chose mythological names related to the Titans of which Saturn was the leader. Some other astronomers liked the system and decided to use it themselves. Eventually these names were adopted generally.
Uranus's moons - a new tradition
In 1852 Lassell asked John Herschel for names for the Uranian moons. We don't know why Herschel abandoned mythology and looked to literature for names. However Uranus was the father of the Titans, so perhaps he felt that he'd already used those names for the Saturnian moons. In addition, since Uranus was also the sky god, spirits of the air might have seemed appropriate. In any case, Herschel proposed Oberon and Titania for the two moons his father had discovered. They are the king and queen of the fairies in A Midsummer Night's Dream. For Lassell's moons he suggested Ariel and Umbriel, spirits of the air from The Rape of the Lock, a satirical poem by 17th century poet Alexander Pope.
It took nearly another century for the next moon to be found. Gerard Kuiper discovered it in 1949. He didn't name it for an airy spirit, but he did choose a Shakespearean name: Miranda, the heroine of The Tempest.
Shakespeare vs. Pope
According to the current naming policy of the International Astronomical Union (IAU), Uranian moons are named either from Shakespeare or Pope's poem. However, although the poem was very well known and highly regarded in Victorian England, it's unfamiliar these days. So it's a bit of a surprise that even one further moon was given a name from The Rape of the Lock. That is Belinda, heroine of the poem.
Belinda was one of ten inner moons discovered by Voyager 2 in 1986. The names of the other moons all came from Shakespeare. But I do think that Mab is a shaky connection. Queen Mab (a fairy) doesn't appear in any play, though Mercutio refers to her in Romeo and Juliet.
Interestingly, since Pope's poem is obscure now, but The Tempest remains familiar, people generally assume that Ariel is the spirit from the play, rather than from the poem. Either way it fits Herschel's theme, of course.
The Tempest and the outer moons
There are nine known outer moons. They are irregularly shaped, have highly elliptical and inclined orbits, and eight of them have retrograde orbits. That means that they orbit in the opposite direction to the rotation of Uranus. They are probably objects captured soon after the planet's formation. The eight were named after characters from The Tempest, following Kuiper's lead.
The odd one out, in various senses, is Margaret discovered in 2003. Margaret is a character in Much Ado about Nothing, the maidservant of Hero. In addition, the moon has the most elliptical orbit of any Solar System moon. Yet while her companions have retrograde orbits, Margaret orbits in the same direction as the inner moons.
By the way, the moons are also still numbered with Roman numerals.