The Gift of the Magi describes Della Young, wife of James Young, and her efforts to buy him a Christmas present with only $1.87, on Christmas Eve. She decides to cut off her hair and sell it, using the money to buy her husband a fob chain for his beloved heirloom watch. James, meanwhile, sold the watch in order to buy a set of combs for Della's hair. The story is tinged with irony but its ending is meant to be charming and inspirational rather than melancholy or depressing.
We can phrase the narrator's knowledge in two ways. Specifically, the narrator knows how the story will end because it is foreshadowed; shortly before Della and James have their gift exchange, the narrator mentions the magi, and their material gifts, and that "This dark assertion will be illuminated later on." I think in this case, "dark" means mysterious or unclear, rather than ominous or foreboding. So, the narrator knows how the story will end, because the relevant lesson is already in mind and will make sense once the ending is described.
In a broader sense, we could say that the narrator knows everything (which James and Della clearly do not). The narrator is omniscient, which is a fairly common practice, and is evidenced by things such as describing Della's thoughts without her saying anything.