Given that I don't think that Gainey is stupid, I personally think he is one of the most astute GM's in the league, I can only think of one scenario that makes this trade make sense.
We will soon hear that Montreal has not only traded for Hossa, but has signed him to a long term deal. WIth that deal signed Gainey knows that he will not be able to afford Huet under the cap for next year, and wants to keep the remainder of the team (minus who goes back for Hossa) intact. So knowing that he will lose Huet anyway, he shopped him for the best he could get for an UFA goalie with no playoff record to speak of. I too am disappointed with the 2nd round pick but I can't imagine Gainey did not explore all options.
This means that Gainey is not only thinking of this year, but thinking more about the next five years for the team, which would now include Hossa.