The use of irony by Maupassant in "The Necklace" helps to convey the moral truths of his narrative.
Situational Irony - A contradiction between the event that occurs and the expectations of a character.
1. In the exposition of this story, Madame Loisel is, ironically, unhappy in her current state as the wife of a civil servant:
She grieved incessantly, feeling that she had been born for all the little niceties and luxuries of living.
Little does she know that the situation will get worse for her during her enjoyment at the reception at the Ministerial Mansion or after she loses the necklace loaned her by Madame Forestier.
2. Of course, the ending of the story has an ironic twist in which Madame Loisel learns that the necklace which she has replaced with a diamond necklace was an imitation diamond and not worth what she has sacrificed for during all her years of haggling with the grocer and scrubbing her own floors as she has been dressed like a peasant.
Dramatic Irony - A contrast between what a character thinks and what the reader knows to be true.
Madame Loisel has felt that it is better to deceive her old schoolfriend Madame Forestier by replacing the lost necklace with another; however, if she were honest, she would have learned that the necklace is not made of real diamonds.
Clearly, the moral truths of the value of honesty with friends and others, and the value of appreciating what one has rather than being envious of more are given impact and meaning through Maupassant's use of irony.