why does he say they most unwisely sacrificed for each other the greatest treasure of their house
In The Gift of the Magi, O. Henry uses irony to convey his message - that material possessions are not the most important treasures in life.
Jim's greatest treasure was the pocket watch inherited from his father and grandfather. Della's prized possession was her luxuriant, long brown hair. Beyond these two assets, the couple had very little in the way of worldly wealth. These two treasures were even more highly esteemed because they were all Jim and Della had that the world would consider valuable.
O. Henry contrasts Jim and Della with the magi, pointing out the wisdom and practicality of the gifts given to Jesus.
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.
He then suggests that Jim and Della, in sacrificing their "greatest treasures" in order to be able to give a gift based on deep love for the other, "were the wisest." In giving their greatest possessions, they truly gave their complete love.