The setting of the poem is the occasion mentioned in the title: Donne's parting with his wife before his long trip to continental Europe. It's helpful to picture Donne holding his wife Anne in these last moments—perhaps on a dock with busy deckhands loading supplies behind them—and seeing her begin to tear up as he starts to go. This poem then becomes his seventeenth-century, awesome way of saying: "Don't cry, baby."
There is a broader context, though, that also helps us understand the poem. Donne lived in an age fascinated by wit, and he ran with a witty crowd of lawyers and other high-society men that would hang out in coffee-houses and try to impress each other with riddles, poems, or plain ridiculous arguments. Donne's work was groomed by this crowd and so, even though this is an intimate love poem, it still has that clever flair to it.
In a sense, then, one setting for this poem is the relationship between Donne and his wife, which he attempts to pacify and settle with the arguments he presents here. He uses both his wit, and this romantic devotion, to ensure that the relationship-setting will hold together, in spite of his upcoming breach.