There are some pretty good answers at http://www.reddit.com/r/AskHistorians/comments/2pq5fa/the_imitation_game_ends_with_the_quote_historians/
It may be time to add this as a FAQ entry.
Counterfactual thinking really has little place in historiography. Historians will rarely use conjecture. When they do, they will usually stress the relativity of said conjecture. We study sources in an attempt to gain insight in past historical realities or possible worldviews, because that's all we could ever hope to substantiate. What you describe sounds more like someone attempting to reason withint the "multiverse" theory. We can't really use historical methods and tools when talking about alternative dimensions or timelines. You could make an educated guess, but that's all it can ever aspire to be.
Edited for clarity
Code breaking might have shortened the European war by no more than a month, and spared a few 100,000 lives, most of which would have come from death camps. Might.
If the code breaking accelerated the West's invasion of the Western Front by a certain number of months, then maybe code breaking shortened the European war by a couple months, and spared another couple 100,000 lives, which again, most would have been from the death camps.
Here is a brief summary of history:
Soviet Union had all the intelligence in the world, including from the infamous Richard Sorge, telling them about Operation Barbarossa. They ignored the signs to a large extent.
During Operation Barbarossa, the Soviet Union suffered casualties on a scale never before seen in history. 3 things slowed down the offensive: The Nazis helping Italy take Greece using Operation Barbarossa forces delayed the start of the offensive by up to 2 months, the Red Army holding out at Smolensk for another 2 months, and then later Hitler tried to solidify his hold over central Ukraine prior to his attempt at capturing Moscow. Those delays leading up to Moscow ultimately assured the war was lost for the Nazis. The '41-'42 winter arrived before the Nazis could defeat the Soviet Union. Could the Nazis have done enough damage to the Soviet Union during Operation Barbarossa to win the war? Maybe if they had another 3-6 months. However, looking at the Nazis' failure to take Leningrad and Stalingrad, then it is very dubious that the Nazis could have succeeded in adequately capturing Moscow before winter set in. Once winter sets in, a pattern emerged during WW2 that illustrates the Soviet Union's utter winter dominance, and it is likely that the Soviet Union could have retaken a contested Moscow with the reinforcements from the far east. Let us just say that the Soviet Union learned a lot from their attempt on Finland.
The importance of Moscow for the Soviets may be overstated though. Had the Nazis taken Moscow, that wasn't necessarily the end of the Soviet Union, but such a scenario is one of the great ifs. Ever since the formulation of the Russian Empire, the Russians have had a European war strategy that consists of constant retreat from the Western plains to cities further east, while letting the winter and mud seasons wreck havoc on an invading army that finds it harder and harder to maintain supply lines. Ultimately, the Nazis may have been fated to lose the European war the moment they invaded the Soviet Union, which was also backed by Western aid, even without the otherwise inevitable use of American atomic bombs.
During early-mid '42, the counter-offensive by the Soviet Union was largely ineffective, and led to the second major Nazi offensive towards Stalingrad and the Caucasus region during mid-late '42. However, the Nazis became stretched thin due to their efforts in the Caucasus region (to get oil), and thus were unable to completely overtake Stalingrad.
Once again, winter came in '42-'43 before Stalingrad could be taken and for any reinforcements to otherwise be spent on building up a defense. The Soviet Union launched their second major counterattack and encircled Stalingrad and all the Nazis within during Operation Uranus. They then forced the remaining Nazi army in the Caucasus region to retreat back towards Germany.
If Germany had adequately conquered Stalingrad and defended their flanks by not focusing on the Caucasus region, then maybe they had a chance at holding the Soviet Union at bay for some time. However, the failure of Operation Barbarossa, combined with the now far-eclipsing industrial output of the Soviet Union and the West during '42-'43, made an overall victory in the European war already very unlikely for the Nazis. The lagging industrial output of the Axis, which was already too deficient to compete with the Allies in '41-'43, would only get worse as the war went on when oil became scarcer and the Allied bombing runs over Germany started to become more and more impactful.
Notice that intelligence gathering played an insignificant part in the dictation of Allied decisions on the Eastern front. The weight of the Soviet Union's war machine after they survived Operation Barbarossa was far more than the weight of any intelligence contributions. The Soviet Union simply rolled over what was left of the Nazis for the next 2sh years following the Nazis' attempt to capture Stalingrad.
If the Nazis' mistakes could be summarized, it was attacking the Soviet Union as late as they did, and without almost everything they had (lots of divisions were in secondary theaters). In other words, the Nazis underestimated the Soviet Union's capacity for rapid mobilization and vast industrial production.
Code breaking contributions:
By the time the Battle of Kursk occurred in mid-'43, about a half year after Stalingrad was encircled by the Soviet Union, the Nazis had already long been assured a defeat. The Soviet Union decisively defeated the Nazis in the Kursk region, due in small part to excellent intelligence, some of which did infact come from code breaking efforts. However, the impact of covert intelligence on the outcome of that battle is most likely vastly overstated, since the Soviet Union was already heavily involved in the Kursk region. Perhaps 100,000 lives were spared(this includes death camps), because of all the additional defensive actions taken by the Soviet Union.
The code breaking exploits certainly reduced tonnage losses in the Atlantic, which helped the supply runs to Britain and made the Western invasion of France far more effective and less daunting. However, the European war was already long over before the Normandy landings, and Britain was never under any threat of an invasion as long as the Soviet Union was alive and kicking. Regardless of what was happening in the Atlantic, with or without the code breaking exploits, the Nazis had to remain prepared on the Western front for an invasion starting as soon as mid-late '42. Instead of the US landing in Africa in '42, it could have been mainland Europe, and the odds of such a Western invasion would only increase as time went on.
If code breaking allowed the invasion of the Western front to happen sooner, then without it perhaps the Soviet Union would not have erected the Iron Curtain through Berlin, but, instead, further west towards the Rhine. In the context of the Cold War, I think code breaking might have had its most significant impact on geopolitical lines. Ending the war years sooner and saving millions of lives were definitely not among its many accomplishments.
Allied contributions to the European war:
Far more effective than code breaking was the Lend-Lease agreements that had the Western powers supplying military equipment and supplies to the Soviet Union. I'd estimate that in material and food alone, the West provided no more than 1/3 of the total produced for the Eastern Front. If you strongly value the US' food contributions to the Soviet Union, then perhaps 1/3 is a fair estimate. However, once you factor in the supply of Soviet soldiers on the Eastern front, then the West's contribution is reduced to no more than 1/5.
The Lend-lease agreement was not very important during '41, which was when the Nazis would ultimately lose the war. Considering the eagerness by which the Soviet Union launched the ineffectual counter-attack after the failure of Operation Barbarossa, then I do not think resources and supplies were in dire need.
Did the lend-lease agreement later assist in the encirclement of Stalingrad and the defeat of Nazi forces in the Caucasus region? Maybe, and that is when Western aid could have been at its most effective in terms of winning the war. How effective? Considering it wasn't until after the Stalingrad victory that the Lend-lease program hit full stride, then I would wager less than 1/5 of the effort towards re-taking Stalingrad and the Caucasus region can be attributed to the West.
However, lend-lease was certainly important in expediting the end of the war by keeping the Red Army sufficiently fed and supplied during '43-'45. How many months were shaved off? Who knows, but the Nazis would have lost anyways.
What could the Nazis have done differently to win the war, or have a far better chance at doing so?
Ignore the Western front and throw everything at the Soviet Union long before they did, and actually capture the major Soviet cities, notably Leningrad and Moscow, before winter set in.
Not invade the Soviet Union and, instead, build up a major defensive line on the Eastern front. Considering Hitler's goals, peace with the Soviet Union was not likely ever going to happen anyways.
The US and/or UK could not have invaded mainland Europe unless the Soviet Union also invaded from the east. Ultimately, the US would have won the war anyways with the introduction of the atomic bomb.
Interesting thought: Of all the wars that have adequately known military casualty figures, the Eastern Front alone likely caused at least 1/4 of all military deaths in human history.
Interestingly, I just finished reading Engineers of Victory by Paul Kennedy. The claim that intelligence shortened the war by two years came (as /u/theXYZT has already stated) from Sir Harry Hinsley. But, in answer to your question, it's not actually based on any kind of calculation, it was just Hinsley's best guess.
I'll let Kennedy take over from here:
Once one attempts to integrate the hidden dimension of intelligence into the story of how the tide turned, a very mixed picture - more bluntly, a confusing one - emerges. For the fact is that usefulness of intelligence varied from theater to theater, from service to service, and from year to year. Intelligence had a value in one encounter but no particular value in another. There is no way of amalgamating the many case studies into some complete rendering of account, and it remains a continual puzzle to this author that such a professional scholar as Sir Harry Hinsley could venture the opinion that Ultra shortened the war by as much as three years. It is not provable.
That whole movie is pretty bogus with the truth. This article explains just what it does wrong pretty well.
The popular historian Alex von Tunzelmann wrote about the historicity of the movie for The Guardian and concluded, "Historically, The Imitation Game is as much of a garbled mess as a heap of unbroken code."
Purely mathematically speaking, WWII caused 73 million dead (according to Wikipedia). Works out to 9.125 million a year. Assuming the two year estimate is accurate, then 14 million seems like a low estimate.
I feel that they would calculate this by figuring out how many attack and troop movement orders they deciphered from messages the Enigma with their work at Bletchley. Any warning could reasonably save a certain number of casualties. Math would be needed to be done to gauge just how many troops are lost in a surprise attack compared to a prepared attack. On average, of course.
There would also have to be math done about the amount of German infrastructure destroyed at opportune moments by Allied air power. Delays in developing better weapons would also have to be figured in, like production delays on the Tiger and other German weapons. Intelligence saves a great deal of lives.
Also, figure in how many Allied supply ships were lost to German U-Boats and shore-based Coastal Reconnaissance aircraft both before and after the establishments of the Convoy system and consider whether or not there was intel available in the strike. Ballpark an average amount of material saved, and consider the growth in effectiveness of Allied air power (through the acquisition of better planes) and the amount of supplies necessary to establish a military force capable of crossing the Channel and eventually holding ports. Figure in estimates of what would have occurred on the Eastern front had the Soviets been forced to deal with adequate German reserves in the dog days of 1943 and 1944 before and after Enigma was cracked, and the Allies had made their landing in Normandy. Figure in how many losses they would have experienced had it not been discovered that the Germans were expecting a landing at Calais.
TL;DR: Take every event that was affected by knowledge acquired from Enigma, and figure out what the losses would have been had they not known that the attacks were coming, and where and when to counter-strike. I'm not saying it's possible to get an exact number or even easy to ballpark it, I'm saying that a decent estimate could be made. But there are many, many variables.