Analogy is a similarity between things that are not intrinsically similar. It is used when one wants to make a point. An example of an analogy is the following one:
Kiko Loureiro, Megadeth's lead guitarrist, explained on a recent video why he did not keep in touch with the members of Angra's original line-up right after they departed and Angra recorded a new album with three new members (Angra was Kiko's previous band). Kiko used an analogy:
"I did not keep in touch with them because I did not want the new guys to feel insecure. It is the same when you start a new relationship: if you keep in touch with your ex-girlfriend, the current one will feel insecure, and she will probably leave you."
A sonnet structure is used because sonnets were used at that time to proclaim love and were often written to loved people. By using sonnet form instead of Shakespeare's regular blankverse he shows that there is love between them.