Moliere confesses to Mr. Jourdain that it is he that is having an affair with his wife Elmire.  In return for leaving, he gets Mr. Jourdain to agree to call off his daughter's arranged wedding - thus giving Elmire the greatest gift he can, her daughter's happiness.

Years later he returns to find Elmire dying and sits by her side, remembering their affair and the events that were the inspiration for many of his subsequent plays.

Thanks Mary C!