The play was probably written later in Shakespeare's career, between 1601 and 1608.
The five acts follow the action of Helena, a lowborn beauty, who pines for the son of her guardian, Count Bertram. She is granted his hand as a reward for curing the King. Later, she tricks him into giving her his family ring and sleeping with her, by posing as Diana, the virginal daughter of a widow. These were his conditions for being her true husband and he agrees to be a good husband in the final act.
Shakespeare's source is most likely a story in William Painter's The Palace of Pleasure, which was in fact a translation of the ninth story from the third day of Boccaccio's Decameron.