Catholic Answers’ Director of Apologetics Jimmy Akin considers this question in his article The Universe of Discourse:
The reference to John’s greatness occurs in a discussion of his role as a prophet (11:7-15). And the declaration of his greatness is occasioned by Jesus quoting the prophecy of the coming prophet (v. 10) who would herald the Messiah (Mal. 3:1). Jesus follows up the remark by pointing to John as the terminus of the Law and the prophets (v. 13) and as the fulfillment of the prophecy that Elijah (or one like Elijah) would come (v. 14).
This explains the sense in which John is greater than all others: He is the greatest of the pre-Christian prophets in the sense that he gets to be the herald of the Messiah himself. Indeed, some manuscripts of Luke’s Gospel give the parallel to this saying as, “I tell you, among those born of women no prophet is greater than John the Baptist” (Luke 7:28, var.). Needless to say, the class of Old Testament prophets is a set to which Mary does not belong.
Mary is the greatest of the saints because she was the person chosen and prepared by God to be the Mother of his Son, and because she freely chose to cooperate fully in the graces given to her and in the vocation she received.