This is a good question. The story by O. Henry is wonderful. In fact, the story is so moving that people often forget to ask what the title has to do with the story. The best way to answer this question is to quote the last few lines of the short story, where the title appear.
"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, possibly bearing the privilege of exchange in case of duplication. 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. O all who give and receive gifts, such as they are wisest. Everywhere they are wisest. They are the magi."
O. Henry is taking this portion from the New Testament, where anumber of magi from the East came to bear gifts to the baby Jesus. According to the biblical story, they travel far an wide and gave gifts of myrrh, frankincense, and gold. O. Henry takes this episode and basically shows the beauty of giving. As he says, it is wise to give, even if the giving is to your own hurt. Part of the reason for this, I suspect, is because by giving you actually receive.