10 When they saw the star, they rejoiced exceedingly with great joy. 11 And going into the house, they saw the child with Mary his mother, and they fell down and worshiped him. Then, opening their treasures, they offered him gifts, gold and frankincense and myrrh.
Matthew 8:19-20 (ESV):
19 And a scribe came up and said to him, “Teacher, I will follow you wherever you go.” 20 And Jesus said to him, “Foxes have holes, and birds of the air have nests, but the Son of Man has nowhere to lay his head.”
How is it possible that Jesus had nowhere to lay his head? What happened to the magi's expensive presents?
I agree that Matthew 8:20 suggests that Jesus did not possess great success in the way the world measures it. The Gospel of Matthew does not tell us the fate of the gifts of the Magi .
Matthew does, however, offer a hint that I believe offers the best case for answering the OP's question without appealing to hypotheticals: the trip to Egypt. I suggest the most plausible conclusion is that the gifts of the Magi financed the trip to Egypt (see note in addendum for further discussion), and maybe re-established Joseph's carpentry trade once they returned to Nazareth.
The flight to Egypt was sudden and unplanned , and would have interrupted whatever work Joseph had ongoing in Bethlehem or planned in Nazareth.
I'll also note that Joseph & Mary probably presented Jesus in the temple and made the avian sacrifice  before the Magi arrived (it's extraordinarily difficult to make the chronology work otherwise ), which indicates that they were poor before the visit of the Magi.
Financial tips for the first century
I'd also like to add some historical context. Having a one-time infusion of money would not make one permanently wealthy (like how most people who win the lottery end up broke). For wealth to last, it must be invested in wealth-producing assets. During Jesus' mortal life, there was no New York Stock Exchange ; the primary wealth-producing asset was land.
If a person acquired (and adequately managed) enough land, they could sustain a higher-end lifestyle for many years to come. This was still true in the early years of American history--the people who made vast fortunes usually did so through land . A "gentleman farmer"  was someone who had enough productive land that the revenues produced enabled him to pay other people to do the work, and still have enough funds to sustain a comfortable lifestyle.
Let's briefly consider two other options for investment. Shipping involved great risks but could also turn a decent profit...however, Nazareth has never had much promise as a port--it would take a flood like no other (except that one in Genesis 7) to turn Nazareth into a flourishing Mediterranean port. Lending was also a means of sustaining wealth--but banking operations then and now tended to find their greatest utility in large cities.
Can there any good thing come out of Nazareth?
John 1:46 makes it pretty clear Nazareth was not a hot real-estate market, let alone a major financial center. In any event we know that Joseph's trade was carpentry, not shipping, banking, or land-management.
Given that Jesus' early years were spent as a refugee, and, after the return from Egypt the family didn't go to Bethlehem but returned to Nazareth, I conclude that:
Joseph didn't have any major assets in Bethlehem
Joseph didn't get into real-estate development or pyramid schemes while in Egypt
The gifts of the Magi provided temporary financial assistance to Jesus' family, especially including their exodus (reverse-Exodus?) to Egypt. The family apparently did not have the means of sustaining that wealth long-term, and so the Magi's gifts were almost certainly long gone before Jesus' ministry.
Lest my humor be taken the wrong way, I most definitely do believe that the greatest treasure the world has ever known indeed came out of Nazareth--the returns are out of this world.
Who spent the Magi's money?
Others have proposed that Joseph & Mary would never have taken for their own use the gifts given by the Magi to Jesus. I do not hold this view, but I respect those who do.
As one who knows a thing or two about traveling to unknown places with new cultures & languages, I do not believe that Joseph would have had immediate access to a normal, regular income in Egypt. We do not know how long they were in Egypt, but I do stand by my suggestion that the best word to describe their situation is: refugees
I submit that keeping the family alive was a legitimate use of the wise men's gifts
I do not believe that Joseph & Mary understood everything about Jesus all at once--in hindsight we can (sometimes) expect Joseph & Mary to have constantly thought of and treated Jesus as larger than life, and that every dimension of their lives was overshadowed in holiness. In real, lived experience, they raised him and at least occasionally forgot some of His mission. They were good but imperfect people, and I don't think pristine idealizations of their family life are accurate.
Did they spend the money on scriptures for Jesus? The scriptures were indeed expensive; there are 2 points that ought to be made though. 1) The wealthy would have private libraries, but for everyone else, the scriptures would have been seen as public documents owned by--and available in--the synagogue--the idea of "the family Bible" is a modern phenomenon and I doubt Jesus' family ever owned a large collection of Tanakh scrolls, let alone had anywhere to keep them. Jesus would have studied in the synagogue. & 2) Modern costs of hand-written documents are misleading, because the relative value of labor and materials has inverted. When buying a hand-made anything today, the overwhelming majority of the cost is the labor. In the first century manual labor was inexpensive--the more weighty cost would be that of the material.
In many ancient cultures, it was held that a man owned his wife and children and that they and all of their belongings were his property. This is not something we like to think about in the 21st century--we recoil at the idea--and yet if we are honest about history this is what happened. Culturally Joseph as the husband of Mary and the adopted father of Jesus would have owned all of the family's possessions. It would have been considered entirely culturally appropriate for Joseph to spend money earned by any member of the family.
To those who disagree with me I will grant that maybe they assiduously sought to avoid these cultural norms out of reverence for Jesus. However, I see Joseph & Mary as good and also human people of their time, and I don't think they saw their world through 21st century eyes. I maintain it is more likely than not that the Magi's gifts were spent for the good of the family.
1 Our favorite tax collector, as much as he may have liked to, didn't supply quarterly balance sheets or statements of cash flows. Or if he did, they have not been preserved in any manuscript variant =).
2 Matthew 2:13-15
3 Luke 2:22-23
4 My own work on the relevant chronology is available here; Jesus was probably at least several months old before the visit of the Magi, long after the sacrifice had been made in the temple
5 As already noted by Tony Chan, they would have sacrificed a lamb if they could afford it, see Leviticus 12:8
6 E.g. see here 7 George Washington being the most famous example, see here 8 See here 9 See map here 10 E.g. see here 11 Matthew 13:55
12 E.g. Luke 2:48
13 E.g. see here 14 Josephus, Against Apion, 2.175
15 See some estimates here 16 E.g. see here
7b “ ‘These are the regulations for the woman who gives birth to a boy or a girl. 8 But if she cannot afford a lamb, she is to bring two doves or two young pigeons, one for a burnt offering and the other for a sin offering. In this way the priest will make atonement for her, and she will be clean.’ ”
Jesus' parents couldn't afford a lamb. Luke 2:
22 And when the time of purification according to the Law of Moses was complete, His parents brought Him to Jerusalem to present Him to the Lord 23(as it is written in the Law of the Lord: “Every firstborn male shall be consecrated to the Lord”), 24and to offer the sacrifice specified in the Law of the Lord: “A pair of turtledoves or two young pigeons.”
At the beginning of Jesus' public ministry, he told the rich young man in Matthew 19:
21 Jesus answered, “If you want to be perfect, go, sell your possessions and give to the poor, and you will have treasure in heaven. Then come, follow me.”
At the time, he would not have much personal possession.
Jesus' ministry itself wasn't rich either as he explained in
19Then a teacher of the law came to him and said, “Teacher, I will follow you wherever you go.”
20Jesus replied, “Foxes have dens and birds have nests, but the Son of Man has no place to lay his head.”
That was the lifestyle of Jesus if anyone wanted to join his ministry. A year's wages were a lot of money to the ministry.
After Mary anointed Jesus' feet, the ministry's money bag holder/accountant complained in John 12:
4 But one of his disciples, Judas Iscariot, who was later to betray him, objected, 5“Why wasn’t this perfume sold and the money given to the poor? It was worth a year’s wages. ”
At the time of Jesus' death, he didn't have much either as John took up the responsibility for Jesus' mother in
26 When Jesus saw his mother there, and the disciple whom he loved standing nearby, he said to her, “Woman, here is your son,” 27and to the disciple, “Here is your mother.” From that time on, this disciple took her into his home.
Was Jesus rich or poor?
From the numerical monentary perspective, at the time of Jesus' ministry, he lived a lifestyle of minimalist.
With great hesitation do I respond to this question. It appears, in true fallen carnal fashion we so quickly spend the gifts God sanctified for Himself.
Was Jesus rich?
By Jesus we assume Jesus incarnate.
This question itself must be qualified even further, to,
WHEN was Jesus rich, if ever?
Was He rich at His birth? No
Was He rich after the Magi visited? Yes
Was He rich age 12? Yes, very likely
Was He rich as a young man prior to His ministry commencing? Yes, very likely
Was He rich after He started His ministry? No
Was He rich at His death? No
Without going into a dissertation about the Magi, suffice to say we know they brought Him(not his parents) gifts suited for a king, not a baby shower gift for an upper middle class family, but a king. Let that sink in because unless you’re thinking high six figures or higher in today’s equivalent market, you’re perception of what a king was and should receive, especially a highly sought after prophesied and expected king, is missing the bar by a long shot.
The Egyptian theory
It is proposed by some that the parents Joseph and Mary used the gifts as means of financing themselves in Egypt. I would have agreed with that hypothesis until recently, except for that fact that it wasn’t their gifts (the magi may have very well have given them separate gifts too) and it was no ordinary child, born of no ordinary means. This was God’s child
“But as he considered these things, behold, an angel of the Lord appeared to him in a dream, saying, “Joseph, son of David, do not fear to take Mary as your wife, for that which is conceived in her is from the Holy Spirit. She will bear a son, and you shall call his name Jesus, for he will save his people from their sins.””
This was God’s child, came by way of the Holy Spirit and just to add insult to injury, the people were HIS people,
“But the Lord’s portion is his people, Jacob his allotted heritage.”
And He will save them from their sins
““Why does this man speak like that? He is blaspheming! Who can forgive sins but God alone?””
Jesus was God, for Joseph and Mary to take His gifts no matter how they would have justified it, would be out of the question. Not even in a life and death situation would they have dared, as righteous people, to touch God’s gifts and assume them in any sense.
What did Jesus buy?
We know that Jesus VOLUNTARILY nullified His divine attributes
“but emptied himself (Greek nullified), by taking the form of a servant, being born in the likeness of men.”
This is important because this meant He had to learn and learning comes by way of reading.
(Jesus speaking) “Have you not read this Scripture: “‘The stone that the builders rejected has become the cornerstone;”
Jesus needed to have access to these Scriptures but not as a man as a boy and no boy would have been given Scriptures to handle. I say boy because
“And when he was twelve years old, they went up according to custom.
After three days they found him in the temple, sitting among the teachers, listening to them and asking them questions. And all who heard him were amazed at his understanding and his answers.”
Luke 2:42, 46-47
How much does a Scroll cost?
Today if I wanted my own hand written copy of the Tanakh I am looking at hundreds of thousands of dollars. Just the first five books would cost upwards of $40,000.
Prior to age twelve Jesus had access to the Scriptures and it is my strong belief that He had them specially ordered, all of them. Or He paid for existing ones. He had to learn EVERYTHING about Himself.
Jesus was no hypocrite
In one instance Jesus speaking to another young rich ruler says these words
“And Jesus, looking at him, loved him, and said to him, “You lack one thing: go, sell all that you have and give to the poor, and you will have treasure in heaven; and come, follow me.””
Jesus would never require anything of anyone lest He were first willing to do the same. It is my personal conviction that Jesus walked the talk and did as He preached.
Jesus as minister
Jesus spent 40 days and nights in the wilderness. Jesus forsake all to completely give Himself over to His Father’s business.
“But the testimony that I have is greater than that of John. For the works that the Father has given me to accomplish, the very works that I am doing, bear witness about me that the Father has sent me.”
And He did so, sleeping wherever He could, often times not even sleeping but praying to God through the night
Sure some might say the following g is idiomatic but it’s true, Jesus borrowed everything from the commencement of His ministry forward. Even finding money in the mouth of a fish to pay His dues
“And Jesus said to him, “Foxes have holes, and birds of the air have nests, but the Son of Man has nowhere to lay his head.””
Was Jesus rich? It is my understanding, in this very condensed answer, that Jesus was at one point in His life very rich. But God didn’t need a businessman to preach the good news of the kingdom, lest people be drawn to wealth, He needed a humble man, so people could see God in Him.