It doesn't necessarily have anything to do with roles or functions. Gender (male or female) makes a difference in marriage, because marriage needs one of each. Gender difference also makes a difference in the priesthod, because marriage is "a great mystery: but I speak concerning Christ and the church." (Ephesians 5:32). So the priest, who represents Christ, is symbolically male; the Church is symbolically female.
Not entirely explicable in human terms: hence the word "mystery."
Which in the end leads to the dignity that is given to both men and women, be it marriage, the priesthood/religious life, and for those who are neither, but are call in a special way, single in the world.