The reason why Chaucer wrote The Book of the Duchess most often is given as a straightforward explanation. Blanche, the wife of his patron (person who commissioned and paid for poems and provided livelihood) the Duke of Lancaster, John of Gaunt (son of England's King Edward III and father of King Henry IV), died (1368) and Chaucer wrote The Duchess (1368-69) as a memorial to her life and death: he wrote Blanche an elegy. Yet other scholars find problems with this explanation. Firstly, the poem deviates from standard elegy form and devotes much attention to the virtue and worthiness of the Black Knight, who is recognized as the representation of John of Gaunt, making the claim of elegy a little less tenable.
Secondly, Chaucer was not a courtier of John of Gaunt but rather was a courtier and emissary for King Edward III and received an annuity (livelihood income) from Edward III before his marriage to Philippa who was in service to Edward's Queen Philippa. While Chaucer accompanied Gaunt in raids to Northern France (1369 and 1370), it was Edward III who earlier paid a ransom (1360) for Chaucer's release from the French.
Thus it is difficult to say (1) that Chaucer wrote an elegy to Blanche, Duchess of Lancaster, or (2) that he received the patronage of John of Gaunt, Duke of Lancaster, since he was in the court of King Edward III. Later, Philippa Chaucer, after marrying, traded her service to the Queen for service to Gaunt's second wife. Gaunt provided Philippa with an annuity, then later, gave Chaucer one too, perhaps to increase Philippa's income through her husband's name.
One reasonable explanation for why Chaucer wrote The Duchess considers the fact that while Gaunt may not have been Chaucer's patron, they were closely acquainted and respected each other: Chaucer was at Gaunt's marriage to Blanche; Chaucer traveled on missions for the King, Gaunt's father; Chaucer and Gaunt were in wars together; Chaucer's wife was a lady in waiting to Gaunt's second wife. Thus it is very possible that the reason why Chaucer wrote The Duchess--with its touches of humorous irony--following Blanche's death is so he could combine a memorial to Blanche with a dream vision bespeaking the virtues of his bereaved friend.
The wondres, me mette in my sweven [dream].
But forth they romed wonder faste
Doun the wode; so at the laste
I was war of a man in blak,
That sat and had y-turned his bak
To an oke, an huge tree.
A wonder wel-faringe knight --
By the maner me thoughte so --
Of good mochel, and yong therto,
Of the age of four and twenty yeer.
Upon his berde but litel heer,
And he was clothed al in blakke.
Chaucer's poetic aesthetic emphasized taking a humorous ironic perspective, not taking himself or others too seriously (though he had serious opinions and convictions). It is reasonable that he would seek to console his friend, who had survived his wife's death, by elucidating his friend's love for Blanche and his virtues that would resist the grief of death.