Why did they spend money and effort to build the infrastructure and organization, collect, transport and house the prisoners while execution on the spot would presumably be easier and less costly? I'm trying to understand the history, no offense or Holocaust denial intended, I tried googling it, it seems that the purpose is to make the killing systematic, but what is the purpose of making it systematic while it seems to just making things complicated and more costly
1) It's much easier to hide the killings if they occur at a remote camp rather than executing people on the spot. The latter would probably have meant a much higher chance of rebellion amongst the Jews, Roma and other people who were killed. Most of the people who were deported to the camps did not know they would be killed.
2) The manpower required is much less compared to executing on the spot. For executing you need lots and lots of soldiers. For the gas chambers, you only need one person to flip the switch.
3) Psychologically, it's easier on the people doing the killing.
That said, counting the number of Jews killed in extermination camps (see here) compared to the total numer of Jews killed, almost 3 million were not killed in extermination camps but via other means.
The purpose of to industrialize the mass execution of Jews and other "undesirables". Prior to creating the execution camps, the Nazis had executed considerable numbers of people "on the spot". This was a time consuming process not only for the actual execution but the sanitary disposal of bodies afterward. Considering that the regime was planning on executing between 12-15 million people, industrialization made sense.
Also, there was concern about the public reaction to performing the mass murder out in the open. By creating the convenient fiction that they were being sent to "relocation" camps, it allowed the German public to pretend not to notice what was really going on. Public outcry would be an even greater risk in occupied/allied nations like France, Romania and Hungary.
If you want to get some further info on it, read about the Wannsee Conference and watch the fairly accurate docu-drama Conspiracy that depicts this meeting.
Goldhagen (Hitler's Willing Executioners), while drawing controversial conclusions, uses standard evidence. Goldhagen's evidentiary basis matches what I've read in Police Battalion studies, for example. So I am using Goldhagen as a handy, widely published, monographical account of modern German genocide studies.
The German genocide in Europe involved three significant components resulting in mass deaths: a) Actions b) Ghettos, concentration camps, extermination camps c) Death marches
In all instances, policy and execution evolved in relation to the concrete situation. Prior to 1941, the scale of the problem with excess undesirable populations was primarily limited to German controlled Poland. Poland had seen limited actions, but primarily saw population transfers into ghettos.
1941 and the invasion of the Soviet Union brought a new scale of problems into being. German war plans for the first year were to occupy everything West of the Leningrad, Moscow, Rostov-on-Don line. Some planning involved the use of forced extraction before winter to starve undesirable populations (all Slavs and Jews). They were highly fanciful plans.
The reality of the situation combined the use of rear area forces with specific anti-Jew and anti-Commissar actions (einsatzgruppen), with supplemental support from wehrmacht units and police battalion units to conduct primarily political pogroms. While there was a great deal of initial success in this method, the problems of excess undesirable population were compounded by Soviet POWs captured in large and increasing numbers. At the same time, the einsatzgruppen started showing signs of overwork, including extreme alcoholism and suicide. Alternatives to the action system were needed as "craft" style genocide was not sufficient for the planned goals.
While Soviet POW camps showed an extremely high mortality rate through deliberate neglect and starvation, this wasn't viewed as adequate. The Wannsee conference authorised the requirement that had already become apparent on the ground: a need for an industrial method of killing large numbers of human beings.
Killing was already systematic, that system of localised actions had become inefficient, and the system put in place mirrored on a larger scale the industrial and homicidal logic behind the mere concentration camps and the Soviet POW camps. As noted above, and in other posts, a significant volume of deaths occurred in late war death marches, or in continued actions or concentration camp starvation and disease deaths during the operation of extermination camps.
I recall a line from the World at War, episode 20 in which a commander remarks that the method of execution on the spot was producing a German nation of brutes and that another means of [genocide] would be preferable.
Originally they were tried to just shoot the people in the ghettos/prisons, but it was having a demoralising effect on their soliders. There's only so many times the average soilder can shoot people at point blank range and not suffer psycological consequences.
Hence they came up with the extermination camps. The "gas showers" thing was helpful for the Nazis because the people would strip off all their clothes themselves (rather than the soliders stripping the corpses).
The problem with shooting people on the fly is that word gets around very quickly that you are doing that and it becomes much more difficult to capture victims in the future.
Cost is not really a factor, because it is relatively cheap to kill people compared to say, fielding a military division.
The means of execution is also relatively unimportant. For example, in the 1930s the way the Soviets killed people is that in each county that made a fenced off area and dug trenches in it. Throughout the night they would arrest people on the lists and bring them in sedans called "black Marias" (or a truck if it was large families) to the special area. Then they would line them up over the trench and shoot them in the back of the head. Then the trench was covered over and during the day a new trench was dug for the next night. Similar methods were used in Cambodia under Pol Pot.
The biggest advantage of using remote death camps was that they were very secret, so this made it a lot easier to lull the victims into a false sense of security and hence capture more of them. It also was beneficial in avoiding negative publicity abroad. Hitler was very sensitive to Germany's "image" and read translated American newspapers regularly. Naturally, he did not want stories of mass executions appearing in those papers.
I'm fairly surprised nobody mention the main purpose of concentration camps wasn't the execution. If was, the prisoners would go to showers as they arrive in the camp.
The camps where useful economically, as the prisoners works every day, as slaves, with production quotas et all. So they are moved to camps not for extermination, but for slavery, then extermination.
Then the showers have other advantage: they are silent. You don't want a prisoner uprising in a camp where there outnumber you by orders of magnitude.
Adding two things to some good points from the other answers:
1) While the Nazis as an organization did horrible things they did not at all encourage individual cruelty as they understood it (i.e. as a Nazi you were supposed to kill Jews as a "necessity" but not supposed to have fun with it). There was a certain fear that exposing the general population to mass murders executed in the streets would corrupt the (alleged) higher morality of the german "Volk" [a]. So the murder of Jews from the area of the "Reich" was relegated to an elite force (which was lauded by Himmler in one of his "Posen speeches" for "having done that [killing the jews] while still remaining decent people").
Note that outside the area of the Reich the Nazis didn't much bother, at least 1,25 mio Jews were rounded up, shot and buried on the spot in the occuppied eastern terriories, and another ca. 400 000 killed in gas wagons [b].
2) Another important factor was disposal of the bodys. There did not exist any facilities that could have dealt with additional (to natural deaths) millions of bodys. This lead to the constructions of the notorious "ovens" in the annihilation camps. The engineers at the german company Topf und Söhne constructed a crematory that could completely incinerate a human body with as little as four kilograms of fuel (coke). This worked only as long as the bodys where properly stacked and the oven was not allowed to go cold, so an influx of bodys at a predictable rate was needed.
So one of the purposes of concentration camps relating to the holocaust was to have a buffer of future victims that could be funneled into the annihilation process according to available capacities for disposal (certainly there were other goals, especially since not everyone who went into a concentration camp was destined to go to a death camp; e.g. the non-jewish inmates would often be places in forced labour camps. For jewish victims forced labour usually meant "Vernichtung durch Arbeit" (annihilation by labour), i.e. they were given jobs that would most certainly kill them).
This applied till end of 1943/ beginning 1944 - when the Nazis realized the war effort wasn't going well they decided to kill as many jews as possible before they lost the war, and the destruction process became a lot more haphazardly (i.e. people were shot and burned in masses under the open sky because victims arrived quicker than they could be disposed in the previously employed manner).
[a] Individual Motivations probably did not always match the ideological framework - for example Eichmann, who for a long time was portrayed as a bureaucratic figure, was later revealed to hold a visceral hatred against jews.
[b] Benz, Graml, Weiß (Editors), "Enzyklopädie des Nationalsozialismus" , München 1997, Page 50ff