Actually it would have been completely within the laws of Moses for Jesus to have been married.
According to some scholars I;ve read, If Jesus was considered a rabbi, a teacher, then according to ancient Jewish law, he would have to be married to qualify for that status.
But not Jesus’ own law.