The moral of the story is that physical possessions, however valuable they may be, are of little value in the grand scheme of things. The true unselfish love that the characters, Jim and Della, share is greater than their possessions.
O. Henry ends the story by clarifying the metaphor between the characters in the story, Della and James (or Jim), and the Biblical Magi. The Gift of the Magi features O. Henry's characteristic twist ending and use of flowery diction.
(Summary adapted from Wikipedia.org)