It makes more sense in context. The full passage is:

27: Then came to him certain of the Sadducees, which deny that there is any resurrection; and they asked him,
28: Saying, Master, Moses wrote unto us, If any man's brother die, having a wife, and he die without children, that his brother should take his wife, and raise up seed unto his brother.
29: There were therefore seven brethren: and the first took a wife, and died without children.
30: And the second took her to wife, and he died childless.
31: And the third took her; and in like manner the seven also: and they left no children, and died.
32: Last of all the woman died also.
33: Therefore in the resurrection whose wife of them is she? for seven had her to wife.
34: And Jesus answering said unto them, The children of this world marry, and are given in marriage:
35: But they which shall be accounted worthy to obtain that world, and the resurrection from the dead, neither marry, nor are given in marriage:
36: Neither can they die any more: for they are equal unto the angels; and are the children of God, being the children of the resurrection.
37: Now that the dead are raised, even Moses shewed at the bush, when he calleth the Lord the God of Abraham, and the God of Isaac, and the God of Jacob.
38: For he is not a God of the dead, but of the living: for all live unto him.

(Bold text is mine).

The Sadducees didn't believe in the afterlife and were trying to find some way of trapping Jesus in a logical dead end. He responded to their question by stating that no one in the afterlife marries. He wasn't disputing the legitimacy of marriage.