The question asked why early 1940s computers were predominantly made from relays. The answer to this question might be simplified if limited to discussion of factual commercial and military activities in the United States from about 1940 to 1950.
Relays were durable, and even as scrap many reclaimed relays worked ok. Tubes were more difficult to find. And tube radios were relatively expensive because tubes weren’t cheap. In essence, with the country in the grip of the depression, there were not many useable surplus tubes prior to 1940. One would not expect to find surplus or used tubes in good working condition because the usual case was such tubes were replaced as they burned out and were thrown away. One may keep a spare tube or two at hand to maintain a working radio. But then after the war began, there were virtually no tubes available at all except those already available in commercial stock. Tubes were allocated for wartime uses with few available for domestic needs. But the relays were good and in computation, using relays was a different story. But tubes, nobody thought much of using them in computing; hard to get, would burn out. Nevertheless, the country was making preparations for going to war.
However one reads the question, given the current retrospective view, the premise to the question and its answer may be biased somewhat, or even considerably, by presently held impressions. In fact, aspects regarding the early development of the computer seem to be clouded by interpolation, conjecture, and speculation, hagiography, and character assassination. The interpersonal dynamics in development of the computer included end-running, ignoring valuable contributions while taking credit inappropriately, refusing to act on a reasonable request, back-biting, etc., etc., etc. Even views of the much later patent case in Honeywell Inc vs Sperry Rand Corp., (i.e. asking too much for due royalties) and the decision itself, are filled with anger and controversy. People of this early 1940s time showing an innocent vital interest in then-current thinking regarding computational technology find themselves in corporate life 30 years later portrayed in conflict with their own corporate interests and now-current entrepreneurial intentions. Royalties were a corporate survival cornerstone. Looking at this question about relays from the viewpoint of the developments of the 1940s, and understanding the needs in extended computation necessary to solve certain war-time problems, a rather different perspective is seen. Maybe the counterpoint of the question should have been asked, namely, why weren't early 1940s computers predominantly made with tubes instead of relays. In fact, development of the computer relied on a simple triode tube circuit that would be used as a relay in electronic computation.
By the start of 1940, the number of functioning, non-analogue, electromechanical relay computers could be counted on one finger. Mechanical hand-assisted calculation with a Marchant or Monroe calculator was the name of the day. Or one skillfully used a slide rule. Prior to 1940, the country was within the grip of the Depression. There was no pressing need for extended computation. Before involvement of the US in the Second World War, the perfection of extended computation was in the development of efficient and innovative analogue devices such as the Bush differential analyzer. Ideas and prototypes were just emerging in the use of electromechanical relays as counting and switching devices useful in rudimentary computation. At least one analogue computational device, the M-9, would be perfected for antiaircraft ballistics use during the Second World War. And successive developments in relay computation would also progress.
Lets digress and examine that aspect. In the United States, the situation in developing calculating machine automata begins in 1937 with George Stibitz building the first prototype relay computation module on his home kitchen table. He worked for Bell Laboratories, and had access to their surplus scrap and reclaimed material. Consequently he was able to get access to reclaimed and salvaged relays that were perfectly functional. Company executives, although unimpressed at first, realized the potential value in Stibitz' device and agreed to finance building a larger version. Bell needed a way to solve their math problems that largely involved math with complex numbers. With the design Stibitz completed in 1938, work began on the requested machine in April 1939 and it was operable in January 1940. Although Stibitz was given leave from Bell Labs and would work for the National Defense Research Committee for a while, and then Office of Scientific Research and Development, he continued in design and development of relay computational equipment with the support of Bell Labs until well after the war ended. Several more advanced relay-based devices were designed and completed under his direction, the last of the most advanced series incorporated error checking, an assembly language, and floating point arithmetic. His general purpose devices were used by the US Navy for ballistics calculations and gun control. And his most advanced systems, the last two constructed, were operable and productive until 1960. They were essentially in fully functional working condition when they were retired.
Also in 1937, Howard Aiken, at Harvard, would propose construction of a large scientific calculator for the extended calculation of problems that were beyond the reach of hand computation. Aiken was a seasoned engineer and was back at Harvard to pursue an advanced degree. But Harvard astronomer Harlow Shapley sent Aiken to IBM, instead. Astronomy requires some hard-to-do calculations. The year was now 1938; Thomas J. Watson, Jr., president of IBM, was sufficiently impressed with Aiken's ideas, that he assigned IBM engineer Clair D. Lake to supervise the design and construction of the Harvard machine. Along with Aiken of Harvard, and Lake of IBM, Francis Hamilton and Benjamin Durfee, both of IBM, would lead in the development, construction, and eventual completion of the Harvard machine. Commissioned by the Navy, the Harvard machine, when completed in 1944, was used in the calculation of ballistics problems. Electromechanical relays comprised the computing engine of the Harvard machine, a massive device. From concept to completion required seven years. When completed, utility of the machine has been characterized as already obsolete. After the war IBM would build one more-advanced relay machine of this type that was programmable; both machines were potentially useful.
So lets look again at the status of relay computation in the early 1940s. In the United States prior to January 1944, there were two working relay computational devices, both built by George Stibitz at Bell Telephone Laboratories. Zuse's work in Germany was not accessible for computation as he struggled to retain his foothold on constructing a working relay computer while trying stay ahead of the war. His prototype relay systems were war casualties, but luckily he was not. And as a citizen of an enemy country, his situation was quite tenuous. He was not able to secure an advanced working prototype until after the war ended.
However, in 1941 as the United States entered into war (ultimately in two world theaters), pressing needs in computation required faster and extended means of computation for ballistics calculations. The US Army Ballistics Research Laboratory required ballistics tables for various artillery applications being used during the war. These needs also could not be fully met by differential analyzers. Even though relays, as such, were very effective, they were only marginally effective at meeting the computational needs of the time. There were no fully assembled relay computers for use in extended computation until just before the war ended. The use of tubes as relay-switching devices really did not differ at all from using electromechanical relays. Using tubes as relays is more efficient because tubes are electronic, they have no mechanical parts, and they are incredibly fast.
In 1941, the attention of industry was directed solely toward supporting the war effort and meeting pressing domestic needs. Industry support for expanded commercial computation was not part of that picture. IBM, nevertheless, did provide businesses with various equipment designed to facilitate tabulating needs. By 1942, war restrictions and rationing were in place. Nevertheless, expansions in computation were necessary to support the computation of ballistics tables needed by the Army and Navy, required a prodigious amount of work in the hand calculation of projectile trajectories. If one knew math and how to efficiently use an electric calculator, one had a secure job. Typically, a skilled computer would require about 20 hours to hand-calculate a single, one-minute projectile flight trajectory for the ballistics table. But the problem was further complicated by factors such as air resistance, a variable number not easily specified or determined numerically. When multiple trajectory calculations were completed for various conditions given a specific use, the end results were compiled into firing tables comprised of hundreds of different trajectories. A computational team of 200 or more would require two to three months for the completion of such a compilation. Whenever a new combination of shell, gun, or firing propellant was used, a new set of firing tables specific to these new uses was necessary. The Army attempted to improve the calculation process using state-of-art differential analyzers, but the limit of using this device was quickly reached - they had hit the wall. Nevertheless, several significant events occurred that were all consequential to needing projectile trajectory determinations, thereby setting forth the future path of computation well into the second half of the 20th century. Somewhat ironically, the machine specially constructed to do the ballistics calculations, was not initially used for that specific purpose.
The US Army was already in a cooperative relationship with the University of Pennsylvania Moore School for Electrical Engineering for computational assistance regarding firing tables (Moore School had a differential analyzer and hired lots of skilled computers) when, in 1942, Dr. John Mauchly, who had recently secured a teaching position at the Moore School, suggested to the School's Army liaison officer Lt. Herman Goldstine, also a Ph.D ballistics mathematician, that calculation of firing tables might be more easily accomplished with an electronic computer. Dr. Goldstine was interested. Mauchly had been working with triode flip-flop counters in aspects of meteorological research and realized their potential use as a module in application to computation. He had also been talking with others (such as Atanasoff and Stibitz) and seeing what they were doing in computation because he saw a pressing wartime need, as the US was preparing for war, and he was in an unique position to evaluate the problem.
J. Presper Eckert, a graduate teaching fellow at the Moore School, had just recently met Mauchly at the School the previous year where Mauchly was taking a defense training course for electronics, and Eckert was helping instruct. Eckert was keenly interested in Mauchly's ideas, and the two became friends. Eckert was in his early twenties yet nevertheless a superb electrical engineer. He was very familiar with triode flip-flop circuits and how they could be used. These circuits had been around for more than 20 years. Eckert and Mauchly put their heads together and submitted their proposal to the Army in a memo dated April 2, 1943, for an electronic computer to produce ballistics calculation results like those "in the computation of a trajectory by hand." Their estimated time required to compute the compilation of trajectory tables for any particular application would be about two days. A contract with the Army was secured, assigning Goldstine as technical liaison, Mauchly in charge of project development, and Eckert in charge engineering design and construction. With Eckert in charge of engineering, a team of about 20 engineers would build this machine.
Although everything to be used was then currently available, fundamental to operation was use of the flip-flop circuit. The use of cross-connected triodes as counting devices had been known since about 1919, and their switching times are incredibly fast. This rather elementary circuit would form the basis for large-scale calculation in support of the war effort. The only problem encountered would be in building the machine. Parts were, at times, unavailable for a while. The design using triode tubes, nevertheless, was innovative, straightforward, essentially elementary, and required nothing that was new.
What, exactly, is a flip-flop? Two triode tubes were cross connected so that when one of the tubes was energized, the other was inactive. If the other tube was than energized, the first would become inactive. This flip-flop triggering scheme, in effect, makes the device an incredibly fast electronic relay. Operation of this device as a counter would be typically at 100,000 counts per second. By arranging these flip-flops into interconnected decade counters, an electronic adding machine is produced. The machine Eckert would construct had 200 such decade units giving the machine a memory of twenty numbers of ten digits each.
The project, classified as secret, took about a year to design and another year and a half to build in the basement of the Moore School. Securing the necessary materials was sometimes not possible due to war-time shortages, and delays in completion of the project were incurred. And the project was over budget, costing about $500,000. When the project was completed in November 1945, preliminary tests were completed. The machine dedication was February 1946. But the first task at hand was not calculation of ballistics tables. This machine, really a massive and fast electronic-relay calculator, was needed to do extended calculations for the Cold War effort in Los Alamos. The Los Alamos group (Teller) needed to know if certain design concepts would work in building an H-bomb.
By 1950, Eckert and Mauchly had already realized they needed leave the Moore School and start their own company if they were going to continue productively in developing large-scale computing machines. Their relationship with the Moore School had deteriorated as the School had pressed them, time and again after the war ended, to sign over their patent rights in the design of the ENIAC, which they steadfastly refused to assign to the University. Mauchly, on assignment from the University's Moore School to the ENIAC project, resigned. Eckert, also an university employee, was fired but technically he had already submitted his resignation, as well. Consequently, these two friends ultimately formed what would become the Eckert-Mauchly Computer Corporation to build and sell the first commercially available electronic computer. The rest is Univac history.
This was an excellent question. The answer provided herein may not have been exactly as sought, but then again, maybe it was. Discussion was limited to activities in the United States from just before 1940 to about 1950. Of course, Zuse’s important work in Germany was also mentioned in context. Information used in preparation of this answer came from personal recollections regarding Eckert speaking at Arizona State University in 1975. He was not embittered but philosophical about the outcome of the Honeywell patent-infringement case. Further information was derived from various sources in researching the answer to this question, including Charles and Ray Eames' book, A Computer Perspective, published by Harvard in 1973. This book is no longer in its original press. Additional information was derived from the reference cited in answering the ancillary question about relays and tubes asked by Dr Sheldon, linked with this question, above.