When describing the two possessions in which the Youngs take pride—Jim's watch and Della's hair—the narrator makes an allusion to two figures from the Bible, the Queen of Sheba and King Solomon, which is also an instance of hyperbole:
"Had the Queen of Sheba lived in the flat across the airshaft, Della would have let her hair hang out the window some day to dry just to depreciate Her Majesty's jewels and gifts. Had King Solomon been the janitor, with all his treasures piled up in the basement, Jim would have pulled out his watch every time he passed, just to see him pluck at his beard from envy."
In the Hebrew Bible/Old Testament book of 1 Kings, the Queen of Sheba was said to have journeyed from an Arabian kingdom (perhaps modern-day Yemen) to bring costly gifts—such as spices, gold, and precious stones—to Israel's King Solomon. King Solomon is described in 1 Kings and other Hebrew Bible historical books as renowned for his great wisdom and unsurpassed wealth.
These allusions are obviously hyperbolic and fanciful. For one thing, these biblical figures lived thousands of years ago, in the 900s B.C.E., not in a 20th-century American city. For another, given these monarchs' tremendous wealth, they certainly wouldn't have lived or worked in cheap apartment buildings like the one the Youngs live in. To the Queen of Sheba or King Solomon, neither Della's long, beautiful hair nor Jim's heirloom watch would have warranted a second glance, much less "depreciate[d]" the Queen's treasures or provoked Solomon's envy.
The story is using humorous exaggeration to show how precious these items are to Jim and Della. The hyperbole helps underscore the point that the watch and hair are inestimably valuable, especially in the couple's drab, financially strained circumstances. By imaginatively placing these fabulously rich figures into the Youngs' poor surroundings, the allusion sets up the story's eventual twist and its lesson that true wealth doesn't consist in material possessions.
At the end of the story, after Jim and Della have exchanged their useless gifts and realized the sacrifices they've made for each other, the story uses an allusion to the biblical "magi" to explain the nature of true generosity.
The magi, as you know, were wise men—wonderfully wise men—who brought gifts to the Babe in the manger. They invented the art of giving Christmas presents. Being wise, their gifts were no doubt wise ones [...]. And here I have lamely related to you the uneventful chronicle of two foolish children in a flat who most unwisely sacrificed for each other the greatest treasures of their house. But in a last word to the wise of these days let it be said that of all who give gifts these two were the wisest. [...] They are the magi.
The word "magi" comes from the Old Persian language via the Greek New Testament. The word refers to the "wise men from the East" in the Gospel of Matthew who journeyed to Bethlehem to honor the baby Jesus. The magi brought Jesus treasures of gold, frankincense, and myrrh. Such precious metals and costly spices were considered gifts fit for a king. The magi's gift-giving is believed to have inspired the Christian and broader cultural practice of exchanging gifts at Christmas.
By alluding to the magi, the story associates Jim and Della's gifts for each other—the hair combs and watch chain—with the magi's costly gifts for Jesus. Obviously, the combs and watch chain aren't comparable to gold, frankincense, and myrrh in their monetary value. The point is not the value of the combs and chain themselves, but that the Youngs' "unwise" sacrifices in order to purchase the gifts—Della selling her hair and Jim selling his watch—reveal what the two "foolish children" actually value most: each other.
In this sense, the story suggests, Jim and Della have learned the true lesson of gift-giving: that it's worth giving up one's most prized possession in order to honor the person one treasures even more, even if the sacrifice appears foolish or wasteful to onlookers. Paradoxically, this kind of "wisdom" makes Jim and Della like the magi, even though they are poor, ordinary New Yorkers, not treasure-laden emissaries. Those who emulate Jim and Della in such giving are also "wisest."
Also, the author, O. Henry, makes this allusion because he assumes his audience will understand the reference ("as you know") and require minimal explanation. An American writer at the turn of the 20th century could expect widespread cultural familiarity with such biblical stories. He plays on that familiarity in order to create his twist ending: although the young couple don't resemble the magi outwardly, they nevertheless share the wise men's generous spirit.
After Jim discovers that Della has cut her hair, she explains that she cut it for his sake, making an allusion to Jesus's words in the Bible that "the hairs of your head are all numbered":
"Maybe the hairs of my head were numbered," she went on with a sudden serious sweetness, "but nobody could ever count my love for you."
The biblical allusion can be found in two of the New Testament gospels, Matthew and Luke, when Jesus instructs his disciples not to be afraid of those who might seek to harm them, because they are of great value to God. The saying suggests that God watches over them so closely and loves them so much that the minutest details about them—like the number of hairs on their head—don't escape his notice.
Della's reference to this Bible verse isn't especially sophisticated. In fact, it's not even clear that she's aware she's making an allusion; it sounds more like an offhand association in her mind, with her bigger point being that her love for Jim can't be "count[ed]." When she went to Madame Sofronie, her hairs weren't so much numbered as assigned a literal price, $20. That price, and for that matter the much higher value both Jim and Della gave her beautiful hair, is nothing compared to her love for her husband, which can't be quantified.
The story uses this allusion to further emphasize the contrast between the value of tangible things, like Della's hair, and intangible things, like married love. It also adds color to Della's character, the "serious sweetness" of the somewhat clumsy allusion making her all the more endearing.