I understand "the marriage of X TO Y" is more common, but could it be said to be grammatically incorrect to say "the marriage of X WITH Y"? If so, why?
They both are prepositions, so strictly grammatically of equal worth. However there is the maxim or quantity to consider: You may get married with all your friends, but you get married to your fiancee. There is also the maxim of relevancy: You could get married with a priest, but you get married to your fiancee.
Common usage of each usually comes down to regionalisms however, though I find that "to" sounds more correct. (I am a British-English speaker/listener).
Grammatically either is acceptable since both conform to the "rules". A preference for one or the other derives from the cultural connotations associated with the word marriage, not from any argument over its lexical category.
marriage with can be interpreted to imply an equality of the partners, while marriage to suggests a power imbalance. That is why J.R suggested and as a further option that carries an even greater connotation of equality.
Have a look at the invitation for the wedding of Prince Harry and Ms Markle. It states "the marriage of ''Prince Henry.. WITH Ms Meghan Markle..." I don't like that construction. The preposition "AND" is more logical and arguably, more grammatical. The couple should be viewed as coming to the marriage/wedding as equal partners.When asked at some later date about the event both will say "I married Harry/ Meghan on 19 May.." or "Our wedding was on 19 May..".or "my marriage TO H/M was on ..." Never "My marriage WITH H/M was on ...".