If you have to be married to enter into heaven, was Jesus Christ married while on earth?
Perhaps we should be a little more specific with regard to your question. You say that one has to be married to enter heaven. I assume you are reflecting your understanding of Mormon doctrine regarding the matter. Actually, there is more than one heaven, and the conditions for entry vary depending on the heaven in question. Paul tells us in 1 Corinthians 15:40-41 that:
40 There are also celestial bodies, and bodies terrestrial: but the glory of the celestial is one, and the glory of the terrestrial is another.
41 There is one glory of the sun, and another glory of the moon, and another glory of the stars: for one star differeth from another star in glory.
It is obvious that Paul’s account has not been recorded in its entirety. In verse 40 he mentions two degrees of glory, the celestial and the terrestrial. In verse 41 he compares them with three types of heavenly bodies. The part left out of verse 40 is the telestial glory, which is the glory that Paul compared with the stars, with the significant statement that the stars differ from each other in glory, where as the glory of the celestial is one glory and that of the terrestrial is one other glory. Here is a very brief explanation of the these three degrees of eternal glory.
After death and the resurrection all people that will have lived on the earth, except the sons of perdition who follow Satan, will inherit one of the three kingdoms of glory.
The lowest kingdom, is reserved for the wicked, who will not be resurrected until the end of the Millennium. They are described in the Mormon Scripture, the Doctrine and Covenants 76:82-89, as
These are they who received not the gospel of Christ, neither the testimony of Jesus.
These are they who deny not the Holy Spirit.
These are they who are thrust down to hell.
These are they who shall not be redeemed from the devil until the last resurrection, until the Lord, even Christ the Lamb, shall have finished his work.
These are they who receive not of his fulness in the eternal world, but of the Holy Spirit through the ministration of the terrestrial.
And the terrestrial through the ministration of the celestial.
And also the telestial receive it of the administering of angels who are appointed to minister for them, or who are appointed to be ministering spirits for them; for they shall be heirs of salvation.
And thus we saw, in the heavenly vision, the glory of the telestial, which surpasses all understanding.
Imagine! In the eternities, after the wicked have paid the price for their own sins and will finally be resurrected, that although they will inherit the lowest degree of glory, it will surpass in glory all understanding! The kindness, mercy and love of our Heavenly Father for his children is beyond understanding!
The middle degree of glory is that of a terrestrial kingdom, compared by Paul to the moon, in contrast to the stars in brightness. The terrestrial glory is reserved for the good people of the earth who nevertheless do not accept the gospel of Jesus Christ. They could be said to be those who obey the Law of Moses.
The highest degree of glory, the celestial, is reserved for those who accept the Lord, Jesus Christ as their Savior and who keep all his commandments. As the scripture says, they shall live by every word that proceedeth forth from the mouth of God. (D&C 84:44)
Among those commandments of God as requirements to enter into the highest degree of glory in the celestial kingdom, a man and a woman must be sealed together as husband and wife for time and for all eternity under the authority and by the power of the holy Melchizedek Priesthood in one of the holy temples of the Lord. If they remain faithful to the covenants they make with the Lord, they will inherit all that the Father has. Again, in the words of Paul in Romans 8:16-17:
The Spirit itself beareth witness with our spirit, that we are the children of God:
And if children, then heirs; heirs of God, and joint-heirs with Christ; if so be that we suffer with him, that we may be also glorified together.
Now to the question, was the Savior married? In the first place, the fact that the marriage of the Savior is not recorded in the New Testament does not mean that it did not happen. If being sealed to an eternal companion is a requirement for entrance into exaltation in the celestial kingdom, then there can be no doubt that the Savior was married. He submitted himself to all the laws of the gospel. As an example, baptism in an ordinance by which those who are repentant and come to Christ are forgiven of all their sins. The Savior was without sin. Yet, in order to be compliant with the law of God, he submitted himself to baptism.
Here is a scriptural evidence, found in Isaiah 53:6-10, that indeed the Savior was married, and had children–
All we like sheep have gone astray; we have turned every one to his own way; and the LORD hath laid on him the iniquity of us all.
He was oppressed, and he was afflicted, yet he opened not his mouth: he is brought as a lamb to the slaughter, and as a sheep before her shearers is dumb, so he openeth not his mouth.
He was taken from prison and from judgment: and who shall declare his generation? for he was cut off out of the land of the living: for the transgression of my people was he stricken.
And he made his grave with the wicked, and with the rich in his death; because he had done no violence, neither was any deceit in his mouth.
Yet it pleased the LORD to bruise him; he hath put him to grief: when thou shalt make his soul an offering for sin, he shall see his seed, he shall prolong his days, and the pleasure of the LORD shall prosper in his hand.
Isaiah is speaking of the Savior, who suffered for the sins of man. Yet Isaiah says that he shall see his seed. That, of course, could not be, were he not to have been married.
There are those who support the opinion that the first recorded miracle performed by the Savior, that of turning wine into water at the wedding feast, was at his own wedding. President Brigham Young speaks to this subject in the Journal of Discourses, 26 vols., 4:, p.260—
“It will be borne in mind that once on a time, there was a marriage in Cana of Galilee; and on a careful reading of that transaction, it will be discovered that no less a person than Jesus Christ was married on that occasion. If he was never married, his intimacy with Mary and Martha, and the other Mary also whom Jesus loved, must have been highly unbecoming and improper to say the best of it.”
B. H. Roberts in his Defense of the Faith and the Saints, 2:, p.272-273 also treats the same topic—
“‘We say it was Jesus Christ who was married (at Cana) to the Marys and Martha, whereby he could see his seed before he was crucified.’-Apostle Orson Hyde, Journal of Discourses, volume II.
“Next let us inquire whether there are any intimations in the Scriptures concerning the wives of Jesus. One thing is certain: that there were several holy women who greatly loved Jesus, such as Mary and Martha, her sister, and Mary Magdalene; Jesus greatly loved them and associated with them much; and when he arose from the dead, instead of first showing himself to his chosen witnesses, the apostles, he appeared first to these women, or at least to one of them, namely, Mary Magdalene. Now it would be very natural for a husband in the resurrection to appear first to his own dear wives, and afterwards show himself to his other friends. If all the acts of Jesus were written, we no doubt should learn that these beloved women were his wives. Indeed, the Psalmist David prophesies in particular concerning the wives of the Son of God. ‘Kings’ daughters were among thine honorable wives; upon thy right hand did stand the Queen in a vesture of gold of Ophir.”-Apostle Orson Pratt in The Seer, page 159.