Like all the best things in Breaking Bad, it's open to interpretation, IMHO. It's obvious the cartel wanted the recipe, not even necessarily a cook. We see that in season 2, when Tuco becomes paranoid and kidnaps Walt and Jesse with the intention to have the cousins drive them down to Mexico. Then, again, at the end of season 4, when Gus flies Jesse down, telling him that his life is now in the hands of the cartel (a dubious play).
The way I see it, there are a few scenarios as to what could've happened. I think, either way, Gus wanted Walt out. I do not think Gus ever intended to kill Walt, but of course, that's why it's open to interpretation. As Gus says to Gale earlier (when he's setting up the lab, it's later in season 4, but timeline-wise, it takes place during season 3), "I do not consider him a professional," when he informs Gale that Walt wishes to cook for him, but Gus won't hire him. This is the scene with the debate about 95% purity vs 99%.
But then we have the last episode of season 3, when Victor picks up Walt saying "there is something wrong with your lab." Mike is there and tells Walt "the sooner we get down there and figure out what this is, the sooner we can all go home, Walter."
But that begs the question, right? What was to "figure out down there?" There are many possibilities, but after re-watching the series nearly 10 times, I'm convinced that Gus never intended to kill Walt...at least not at this particular juncture. Which is what makes him such a complicated character, as he slits Victor's throat with ease in front of Mike, Walt, and Jesse. If Gus wanted him dead, he could've done it then: Victor knew the cook, Gale had it written down (though it was confiscated), and Gus recorded everything in the lab, thus recording the cooking processes.
In fact, Gus had multiple opportunities to kill Walt: when he comes over to make stew and Gus pulls a knife, then hands it to Walt. And especially when Gus fired Walt in the desert. Before, in the desert, too--after Walt killed Gus's gangbangers who shot Tomas. Mike even says on the phone in that scene, "Walter, I can kill you from way over here if that makes you feel better." Gus never informs Walt about the cousins coming to assassinate him (though Walt figures it out later). Gus leverages Hank's life in place of Walt's. If Gale or Jesse were to be Walt's successors, why would he barter Hank instead of Walt?
I believe Gus is arguably the most reasonable, rational, and even compassionate character in the show. Knowing Gus's backstory--and his quest for vengeance against the cartel--isn't just for power or control. It's to atone his hermano's death when he was shot in the pool. I also think Gus speaks truthfully when he asks Walt "are you asking me if I ordered the murder of a child?"
However, something was to happen in that lab.
These are all the possibilities I can think of:
Mike was sent to fire Walter. Hell, Gus may have even been in the lab, himself. The "chemical leak" could have been an excuse to let Walt go, have him remove personal items, clean out the fingerprints, etc. As mentioned earlier, Gus fires Walt anyway at the end of season 4 (ep. 13). Jesse is the new cook, Walt is out. If Gus wanted to kill Walt, he would've done it then, too. But never did.
Gus was planning to take Walt to Mexico, in place of Jesse. We know the cartel wants the recipe, both from Tuco's perspective--as well as Gus's later, when he's sniped at with Jesse, at the single-wide trailers. Gus needed a way to get rid of Walt and Mexico was a viable option, considering Walt's increasing paranoia and lack of professionalism (to Gus). It's an easy way to get him out and have him out forever. Whatever his fate was, it was up the the cartel. Gus, at one point when he invites Walt over to dinner, confesses he's a family man--that he does this "to provide" as well.
Mike/Gus/Victor/All wanted to find Pinkman to replace Walt. Mike and Gus knew Walt killed the two gangbangers even before he confessed. Mike knew his car was jacked up; all they cared about was finding Jesse. It's not unreasonable to assume Mike would "beat it out of Walt," just as he threatens to do so with Saul, under Gus's orders. Very likely, they could've tortured Walt until he gave it up. In fact, when Walt gives up Jesse to save his own life, Mike stops with the inquisition and gives Walt his phone. Walt betrays him and sends Jesse to kill Gale.
Mike/Gus/Victor wanted to use Walt to find Pinkman. Both to succeed Walt and to help with the Mexico plan, as Gus learns over time that Jesse is more loyal and dependable than Walt. Mike got the "address" from Saul but never went down the wild goose chase. Mike is smarter than Walt, Pinkman, and Goodman combined and probably figured out it was a rouse in under and hour. Then he deduced that Pinkman was still in town and the only way to get to him was Walt. Gus wanted to set things straight, as he did with Walter in the desert when he says "you should have come to me and let me handle it," referring to the death of Tomas.
Kill Walt. However, this seems extremely unlikely, as Walt was the only connection to Jesse. Perhaps Mike could've tracked him down over time ("it's what I do, after all"), but time was significantly of the essence. Gus couldn't afford to draw more heat and attention. Also, consider the fact that Gus never tries to kill Walt--even after he temporarily turns Jesse. Yes, Jesse says he won't cook if something "final" happens to Mr. White. But think of how clever Gus and Mike are. Shit, they killed the other twin in the hospital, making it look like he succumbed to his injuries from Hank! Gus and Mike could've made it seem like Walt finally died of cancer. But never did. Even as Gus grows suspicious of threats against his own life, his only concern is killing Don Eladio et al and proving it to Hector. His quest for vengeance ironically sealing his own fate at the hands of Walt.