Spoiler
There is also, of course, another possibility. Foamfollower was "given" Vain so that he could pass him on to Covenant. He clearly says this when he meets Covenant in Andelain. This suggests that the ur-Viles actually communicated with him, at least, so they could present Vain to him (in particular, explain about the command word and so on). I seriously doubt that Foamfollower counted as one of the ur-Viles's Dead, so this must mean that: either the Dead could manifest in Andelain without need for their "caller" to be there, or the ur-Viles could somehow summon the dead and/or communicate with them through their lore. If this is true, it isn't a stretch to imagine that the ur-Viles learned something from the Dead in the same way as Covenant was cryptically warned about his voyage: it is even possible that the ur-Viles consulted with the Dead and learned from them that Covenant would leave the Land in search of a new Staff of Law, and that he would do it in the company of giants. Remember also that the ur-Viles were not overtly hostile during the time of the Old Lords, so they might have had contact with Giants back then (in fact, they didn't become hostile until Lord Foul betrayed the Council, at which point they became his tools). Then it wouldn't be too much of a stretch for them to use logic to reach the following conclusions:
1) No one in the Land knows how to make a Staff of Law or where the One Tree is;
2) The only way for TC to leave the Land is with Giantish help;
3) The Giants dealt with the Elohim in the past, and knew of their capabilities and knowledge;
therefore
5) The Giants would lead TC to the Elohim to find out where the One Tree was, or how the Staff of Law could be forged.
Since we don't know exactly the depths of the ur-Viles' lore, it is possible that they might have deduced the whole thing out of the same kind of cryptic remarks the Dead gave to Covenant.
Ok, so that might explain why Vain was created and how the ur-Viles could know about the Elohim. But why did the Elohim attempt to destroy Vain when he was escaping from Elemesnedene? And why did Findail try to do the same when the party started approaching Mount Thunder?
Well, as to the first, I believe at least a partial answer can be found stemming from the theory Wayfriend proposed, that the Elohim created their plan in haste as a response to the unforeseen dychotomy of Sun-Sage and Ring-Wielder. We know that despite the apparent remoteness of the Elohim, they are creatures of passions: we see that during the test they give to the group who enters Elemesnedene, in Findail's despair, in the story of Kastenessen. It makes sense: Earthpower is not an emotionless power, but is driven by powerful passions, as Mhoram discovered in TPTP. So it is possible that:
1) The Elohim imprisoned Vain in hopes of making his purpose inaccessible and increasing the pressure for Linden to take the ring from Covenant (or, in better words, for Covenant to give his ring to Linden);
(Their original plan didn't call for Vain's destruction; as said before, they simply would have imprisoned him to increase pressure, but they would have released him if the worst-case scenario would have come to pass. This also explains Findail's presence and Appointment: he was there in a dual role - to try and keep pushing Covenant into giving his ring to Linden (witness how Findail always keeps from the party anything they might find of use to escape their various predicaments), and as a "safety valve" in case Vain needs to be used.)
2) Vain's escape was not expected by the Elohim who had imprisoned him;
3) The Elohim, seeing their new plan crumble shortly after they had even developed it, simply panicked and decided that if they couldn't keep Vain imprisoned, it would be better to destroy him, even if this would effectively remove any safety valve they might have planned to have. They might have believed, in their usual arrogance, that Findail would eventually be able to persuade Covenant to give his ring to Linden, and that therefore the risk of destroying Vain was actually tolerable.
As for why Findail wished to destroy Vain toward the end, well, obviously he was driven by despair: he could see his own purpose approaching, he could see that Covenant wasn't in any hurry to give his ring to Linden, and he could see what he thought was Covenant's decision - to surrender to despair and give Foul the ring. Basically, at that point all that Findail could see pointed at the fact that even the worst-case scenario was unlikely to happen, and that more likely Covenant would simply surrender the ring and Foul would destroy the Arch. So Findail attempted to kill off Vain because he hoped to increase pressure on her, so that she would be forced to take the ring from Covenant. And he very nearly succeeded: Linden did wrest control of the ring from Covenant when they were facing Foul.
From Findail's point of view, before he tried to kill Vain, the possible outcomes of their confrontation with Foul in order of likelihood were:
a) Covenant gives ring to Foul and Foul destroys the Arch;
b) Covenant fights Foul, but Ring-Wielder and Sun-Sage are not the same, and a new Staff of Law is needed;
c) Linden takes the ring from Covenant, destroys Foul and remedies to the Sunbane without need for Findail;
d) Findail gets a hold onto Covenant's ring and does what he has to do.
Given that both of the most likely possibilities were also the worst as far as Findail was concerned, he undoubtly panicked, and in any case he figured that if he removed Vain from the equation, he might remove option (b) and possibly shake Covenant and Linden enough for option (a) not to come to pass.