Luke 2:5
He went there to register with Mary, who was pledged to be married to him and was expecting a child.
How little credit we give to Joseph. He had to be a man of great faith, discipline and love. In a time when such things were not acceptable, he was seen as a man who had had sex with a woman before they were married.