The giant robot in Japanese comics first appeared some time around 1943. World War II was beginning to take its toll on Japan as a nation. The rationing was becoming tighter, more and more men were being pressed into service, and bombing raids became a drain on morale to which the average civilian had no response.
It is possible that out of this frustration came the first giant robot cartoons. Examples can be found in magazines and newspapers of the era. A cartoon from a 1943 edition of the magazine Manga depicts an enormous mechanical man, bristling with guns, kicking over buildings with the spiked soles of its feet. The caption read "The science warrior appears in New York."
There's a lot in that caption. It's not just a dream about the divine wind of the gods, or some sort of iron deus ex machina, but an idealized tool of a modern industrialized nation to strike back actively at it's enemies.
It sorta makes sense, you know? The fantasies of the United States in the 1930's produced Superman, a man "more powerful than a locomotive": he was able to overcome gangsters, avert natural disasters, and thwart people who were enemies of The American Way of life. A person who was still able, as an individual, to fight things that were too big for any one regular person. The Great Depression was the backdrop for that sort of fantasy.
The idea of a mechanical guardian, a creation of science who can fight to protect you from a threats you can't control, affect, or even imagine in their entirety, sounds pretty appropriate for the 40's. Which is not to say that Giant Robots don't still kick ass, 'cause they do.
"Crush them now, Giant Robo!"
By the way, check out Manga! Manga! The World of Japanese Comics by Frederik L. Schodt for a great history of manga, as well as the picture of "the science warrior" appearing in New York.