Context is important for a deeper understanding of any text, and this one is no different.
The most obvious point, de Sade is in prison. Again. For kidnapping and sex crimes. Unsurprisingly.
While in Bastille, he was far from the opulence that he preferred, though he still managed to be a pompous brat, sending his wife around to get various things for him while he was imprisoned, the worst, yet most unsurprising, of which were anal dildos. Which he wanted customized. (I feel so bad for her.)
I think the extravagant feasts were part of this too. He was eating prison food and wanted the fancy dinners of his youth, or however you want to phrase that.
While in prison, he was kind of left to his mind to think. He then created a piece that showcased both is fantasies, wants, and desires, as well as his political commentary on the current situation France was in.
The main setting, I feel, comes from de Sade wanting to “fix” his “mistakes”. He has this whole… thing… take place in a castle that has been sealed shut, is in the middle of nowhere, that is in the middle of nowhere, and the one village that’s on the very outskirts have been instructed not to let anybody through. This might come from de Sade’s personal failure in that a girl he sodomized escaping and running to authorities, as well as his little experiment with a similar tactic in his own life where he had a few young servants all alone in a manor of sorts which he locked at night. He apparently saw succsess in this and perhaps, longed to go back to this time in his life.
(The four main libertines also never really face any punishment for all of the shit they do, literally and figuratively, so that might be saying something about his own life aswell, though it could also be political commentary. Though, I don’t see why it can’t be both.