Bethlehem enters the Hebrew Bible as a small place with large associations. The book of Ruth is set in its barley fields and ends with the genealogy that runs to David. First Samuel brings Samuel there to anoint the youngest son of Jesse. Micah addresses it as little among the clans of Judah and promises that a ruler will come from it, a line the gospel of Matthew quotes directly.
The two gospels that describe the birth of Jesus reach the town by different routes and this is worth stating plainly, because harmonised nativity scenes conceal it. Matthew has the family already in Bethlehem, with magi arriving at a house, Herod ordering the killing of the children and a flight into Egypt, and only afterwards a move to Nazareth. Luke has the family living in Nazareth and travelling to Bethlehem for a registration under Quirinius, with the child laid in a manger because there was no room in the guest place. Mark and John show no interest in the birth at all. What the two accounts share is the claim that the Davidic promise landed on this particular village.
Veneration of a specific cave here is early. Justin Martyr, writing in the middle of the second century, says Jesus was born in a cave near the village, and Origen a century later reports that the cave was pointed out to visitors, including non-Christians. That continuity of local memory, whatever its origin, is why a church was built over the spot within a few decades of the empire's conversion rather than anywhere else in the town.