The law the Sadducees are quoting comes from Deuteronomy 25:5. In ancient Israel, to be a childless widow made you vulnerable and one of the weakest in that society. So this law from God for his people was to make sure that women were protected and had family and financial security, even when their husbands had died.
The Sadducees don't believe in life after death and so they've concocted this deliberately ridiculous scenario where seven brothers are fighting over the same wife in heaven. They hope that Jesus will see just how ridiculous the notion of resurrection really is but in fact, it's really just their notion of resurrection that's ridiculous because they've missed the whole point of living forever. God doesn't want people to live with him in heaven just so they can carry on where they left off. If the Sadducess knew their scriptures better (our Old Testament), they would have realised God's plan all along is for us to be his people and for him to be our God (Exodus 6:7, Leviticus 26:12, Jeremiah 7:23, 11:4, 24:7, 30:22, 31:1, 31:33, 32:38, Ezekiel 11:20, 14:11, 34:30, 36:28, 37:23, 37:27, Hosea 2:23, Zechariah 8:8, 13:9)! Heaven is not about carrying on as we are but about being in perfect relationship with God forever. The whole Bible is about this love story and everything points to Jesus as the one who would make it possible by his life, death and resurrection from the dead.
So in heaven, for those who have trusted and followed Jesus, it's not about being married to other people but about being married to God (Revelation 19:9, 21:1-4). Even the best marriages on earth are just miniature pointers to this and so when it happens, the pointers will be redundant because we'll have the real thing.
Steve Curtis Chapman sings a song called 'More to this Life' and in the chorus it says:
But there's more to this life than living and dying,
More than just trying to make it through the day;
More to this life, more than these eyes alone can see,
And there's more than this life alone can be