If Joseph & Mary returned home as soon as their Judean business was finished, as Luke 2:39 seems to say that they did, then why was Mary even along for the journey at all? Did the census require women to register in the land of their husband's father? Did the Nazarene community ostracize her so badly that she had to be near Joseph at all times until the baby was born? I doubt option one very seriously, but if option two is correct, then why should they go back to Nazareth?
The fact that Luke puts Mary in Bethlehem at all makes it highly suspect that Luke 2:39 is accurate to the letter. Luke's own readers must have wondered. Really? "All" had to go to be registered? (2:3) But otherwise, why would Mary even be down in Judea? It obviously makes no sense that Mary would prefer to give birth in a borrowed room in a strange city with seemingly only her husband around for help! Plainly, women about to give birth should have remained at home, with her relatives and whatever passed for the local community midwives all remaining nearby.
The only reasonable inference as to why Mary would be in Bethlehem is to suppose that Mary *had* been somewhat ostracized from the Nazarene community and that Joseph was moving his new family down to Judea for permanent residence. But in that case, again, why does Luke 2:39 say that they went back "when" all of their Judean business and post-birth requirements were finished. Really?
To me, it seems like Luke 2:3 and/or 2:39 has some purposeful 'squishyness' pre-built into its wording.
Of course, if Matthew's testimony is true - that Joseph & Mary had a "house" and a "child" in Bethlehem, before fleeing to Egypt - and if Luke's basic narrative is accurate about Mary being from Nazareth at the time of betrothal and conception - then the most obvious solution would be to conclude that Mary & Joseph must have chosen to leave Nazareth, because of the scandal, and relocate to live with his family in Bethlehem.
The only interpretive trouble, at that point, is at 2:39... and perhaps also at 2:3.
We cannot know for sure whether Luke knew about Matthew's testimony, but if Luke did know, and if Luke had some reason to avoid telling the Egypt digression, then the squishiness of 2:39 would fall down to one word: "when". The sentence, "when they finished all things, according to the Law of the Lord, they turned back to Galilee" now seems... well, misleading, at the very least. On the one hand, if Luke knew about Egypt, he's been willfully inaccurate. But if Luke didn't know about Egypt, the directness of his "when" shows either sloppy work or a misunderstanding of true facts.
None of these options encourages faith in the so-called inerrancy of scripture... and certainly not the most politically useful versions of "inerrancy"... which is probably one reason why Evangelicals shrink from historically reconstructing these events, plausibly.
Personally, for the sake of historical sanity and a reasonable super-narrative, I'll quickly opt in for a squishy word or two and a Luke who's deliberately misdirecting the audience at some points. Maybe Egypt was left out to avoid angering Herod's descendants, two of whom sat in at one of Paul's trials. Or maybe Luke didn't know why Mary went along OR that anyone went down to Egypt. Maybe "all" (in 2:3) was Luke's slapdash and deliberately vague effort to explain what he'd heard and believed to be true, that Mary gave birth to Jesus in Bethlehem.
Maybe something else explains Luke's apparently rough seamed transitions. I don't know. But at any rate, if Matthew 2 is at all accurate, then Luke 2:39 must be somewhat 'squishy', in fact, regardless of Luke's unknown intentions.
Otherwise, if the implication is that Joseph & Mary had planned to remain residents of Nazareth, after the census, then Mary should have stayed home and had the baby with family nearby, in Galilee.