This is a good question. There are many themes in O. Henry's short story, "The Gift of the Magi." Let me give you three of them.
Perhaps the greatest theme of the short story is generosity. This theme is underlined when the reader is let into the world of the two main characters, Della and Jim. They are poor. They have been saving all year long and still they have little money to buy anything for each other. In light of this, they sell their most prized possession to have enough money to buy a gift for each other. Della cuts her hair and sells it; Jim sells his gold watch. Generosity is show through sacrifice.
Second, the whole short story is about true love as well. If we ask why Della and Jim do what they do, we can say that it is on account of love. Della and Jim might be poor in material possessions, but they are extremely wealthy in love.
Della and Jim give each other the best of all possible gifts, love. It does not matter that Jim no longer has the gold watch to display on the elegant chain that Della gave him. Nor does it matter that Della no longer has long, luxurious hair to comb with the gift Jim gave her. What matters is that they have is each other.