Mistaken identity is central to the plot of Shakespeare's Twelfth Night. When Viola washes to shore in Illyria in act 1, scene 2, she believes her twin brother has died in the shipwreck they were both in and assumes his identity, both because it will be safer for her to appear to be a man than an unaccompanied woman and in order to gain employment with Duke Orsino. Her disguise leads to the central love triangle of the play: Olivia, mistaking her for the man she is masquerading as, falls in love with her, while Orsino, also believing her to be a man, is oblivious to the fact that she has fallen in love with him.
Viola's famous monologue in act 2, scene 2, beginning "I left no ring with her, what means this lady," centers on the theme of mistaken identity as Viola becomes aware of Olivia's misplaced affections, saying,
Poor lady, she were better love a dream.
Disguise, I see, thou art a wickedness,
Wherein the pregnant enemy does much.
Here, it is clear that Viola regrets her decision to pretend to be Cesario, as she realizes that being mistaken for a man has led to a sticky situation that will end with Olivia getting hurt. She compares her alter ego to "a dream," as both are unreal.
Things are complicated even further when Viola's twin brother, Sebastian, washes up to shore as well, very much alive. With both Sebastian and Viola-as-Cesario wandering around Illyria appearing to be one and the same person, the other characters of the play have conversations with one assuming it's the other, leading to much confusion and even a fight or two as the play barrels towards its climax. Ultimately, Olivia marries Sebastian, believing him to be Cesario, confusing both Orsino and Viola when she approaches them and claims that Viola/Cesario is her husband. Sebastian, for his part, is shocked that Olivia has offered her love to him without him ever having spoken to her before.
In the end, Viola and Sebastian meet face-to-face and are able to untangle everything that has come to pass, realizing that they have been repeatedly mistaken for one another and clarifying who is who to Olivia and Orsino.