Hello. You did not say what text this question refers to, which makes it impossible to answer. However I can help you by showing the concept of anecdote and the possible reasons why it is used.
The anecdote is a short narrative that has a playful and amusing character and its main objective is to provoke comic relief in a narrative, or to satirize a situation and show concepts in a fun way.
Probably in the text to which the question refers, the anecdote serves to convey a comic relief in the text, in addition to showing a criticism, in a light and fun way to the complaining behavior of the husband.