The Airbus A330 and A340 are the direct result of a study airbus conducted in the late eighties regarding long rang flight. It was found, that on shorter routes, a twin is most economical, and that for longer range operations, a quad. The concept of a tri jet is a comprimise between both. The reasons are many, and complex, so i will just brush over the surface. Firstly, we will look at the engines. As you may well know, all aircraft engines must have more thrust than needed to maintain flight in the advent of one engine failure. For a twin jet, you must have a minimum of 50% excess thrust availible for each engine. For a quad, you must have an excess of 25%. A trijet must have at least 1/3 excess thrust availble. In the case of a quad jet, having only 25% excess thrust means that the engine can operate closer to its ideal efficiency. This means, on long range flights, lower fuel burn, and thus greater range. But it doesn't end their - that is just the beggining. Next, one should consider wing structure. The wing of the A340, for instance, is lighter and not as strong as the A330. This is due to having an extra 2 engines weight pulling down(to counteract the wing flux that is a direct result of lift), and the fact that the engine weight is dirstributed more evenly over the wing. The A330 requires substancial reinforcement in the wing to conteract the lift. So, the A330 wing is more expensive, heavier, and allows less room for fuel.
But, the A330 only has 2 engines that need to be maintained. This means significantly less labour hours, and parts savings in the engine. Although each of the CFM 56-5 engines on the A340 cost less to maintain than, for example, A RR trent 700, the total cost is higher when it is done 4 times verse twice. So, Airbus found that for shorter operations, with all of these considerations combined, it is more ecconmical to operate a twin jet, and for longer operations, a quad jet is the most efficient by a long shot. For the A330-A340 family, the crossover point is somewhere between 5 and 7 hour flights, depending on the type and the operator.
It is for this reason that the Boeing 747-400 is still the most efficient aircraft in the sky in terms of seat mile costs on long haul operations. And, it is for this reason, that boeing produced the 747-400, and not a twin jet at the time. Also considering this, when the 777 was iniatially concieved, it was to be a tri-jet. But, its target market was not ultra long range flights, although there are some versions avialble that have a quite long range.(in the same fashion the A330-200 has). This is why, the 777-300 even exists. And why, asian airlines have bought it and fly it on the routes that are typically four or five hours, where they once used 747-200s. (or even shorter distances for that matter).
Well, thats basically it. As i said earlier, it is a complex subjet, and you could write a book on it easily if you wanted to go into too much detail and specifics.