Out of the four gospels in the New Testament only two of them have any detail on the birth of Jesus. Each story, the one in Matthew and the one in Luke, are quite different but contain the authors attempts to explain two bits of information. The first is that the Messiah (the anointed one) would be born in Bethlehem. The second is that Jesus was known as Jesus the Nazareon/Nazarene/Nazerite. The author of Matthew takes the view that the family have always lived in Bethlehem, and then they have to flee when an evil king attempts to kill all the young children in the land. They finally end up in the town of Nazareth. The author of Luke takes a different approach. He postulates that the family originally came from Nazareth but were forced by the Romans to visit Bethlehem where the birth took place. So why did the authors feel the need to create stories about these two facts? One possibility is of course that there was a historical Jesus and people knew that he had been born in Bethlehem but grew up in Nazareth. But there are other possibilities too.
Bethlehem was known for being the birthplace of the Israelite hero King David. The monarchy that ruled Judah for hundreds of years claimed descent from David and euphemisms were used to describe people who were part of this family. Of the Root of Jesse (David’s father) was one, and Born of Bethlehem was another. After the fall of Judah many prophecies were made about the return of a King of Judah and it was expected that it would be a member of the royal household who would take up the reign. And so the prophecies predicted that the Messiah (the anointed one, or King) would be of the Root of Jesse, or Born of Bethlehem. So when Jesus was declared the Messiah some thought it necessary to show his credentials. Both Matthew and Luke give long (differing) genealogies to show how Jesus was literally descended from King David. But they also both took the idea of being Born of Bethlehem literally and placed his birth in that city.
This brought up a problem though. Jesus was supposed to have lived in Nazareth. Or was he? Nazareth had existed in ancient times but had been abandoned for many years by the time Jesus was supposed to have lived. It was only repopulated around the middle of the first century, decades after Jesus’ death and resurrection were placed. So why did people think he lived there? It could have something to do with the name, Jesus was known as a Nazorene, which could mean someone for a particular Jewish sect. In modern terms it would be like saying Jesus the Methodist, or Jesus the Sunni. As the incarnation of God Almighty it seemed strange to later generations that Jesus would be from a particular sect. And so the solution was to place his hometown as Nazareth thereby changing Jesus the Nazarene to Jesus of Nazareth and allowing him to be sectless and someone everyone could worship.
Ideas about Jesus were varied from the get go, and the gospel authors attempts to explain these ideas were often as varied as people’s attempts to reconstruct the early church and Jesus’ life today.