Watching anime, it can often seem that Germany and German culture are a rather significant presence--much more than an American might expect, at any rate, be it in Japanese steampunk (as with a number of Hayao Miyazaki movies), or Western characters in contemporary-set anime (a surprising number of them being German or part-German).
Interestingly, despite the oft-cited parallels between the two countries (whether as rising powers of the late nineteenth centuries, revisionist and fascistic powers in the 1930s, allies in the Axis of the 1940s, post-war scenes of American occupation, or much-hyped economic superpowers in the 1980s), not much has been written about the relationship between the two countries. A rare exception is Bernd Martin's book fascinating Japan and Germany in the Modern World--a collection of that scholar's previously published essays about the subject.
In the long article, "Fatal Affinities: The German Role in the Modernization of Japan in the Early Period (1868-1895) and Its Aftermath," he offers his fullest treatment of the subject. During these years, he notes, Japan, in the midst of the Meiji Restoration and strenuous, top-down efforts to emulate Western nations, Japan considered several models--the United States, Britain, France, Germany--and found Germany the most attractive.
This was, in part, a function of Germany's successes these years--Germany's defeat of the highly regarded French army in the Franco-Prussian War, its revolutionary advances in science and technology (e.g. the modern chemical industry), its rapid rise to the status of industrial superpower, for example. However, as Martin notes, other factors were involved. One was that in contrast with the United States, which had sent Commodore Perry and his "black ships," and imperial Britain and France (which had only recently attacked China in the Second Opium War), Germany seemed less threatening to Japanese independence than the other Western nations, and potentially an ally in its efforts to assert its own sovereignty (an area in which Germany never quite lived up to Japanese hopes).
The other, even more important factor may have been that not just German political ambitions but the German social model seemed less threatening. Japan's revolution, after all, was an intensely conservative one, the country's leaders intent on preserving the traditional social structure--because, above all else, their concern was for the preservation of the privileges that structure afforded them. In comparison with republican America and France, and the liberal constitutional monarchy Britain presented, Germany's more authoritarian, militarized political and social order--centered on the imperial ruling house of the Hohenzollerns and its associated, feudalistic aristocracy (the Junkers) behind its pretense of constitutionality--seemed to hold out the hope of reconciling that structure with Industrial Era economic and military power.
Perhaps the most conspicuous expression of this was Japan's drafting its new constitution after the German model. However, it also manifested itself in subtler ways. Japan did not get very many more of its foreign advisers from Germany than it did other Western nations, but those advisers did have more influence--for instance, in their role in the founding years of Tokyo University. The country's reformers were also more inclined to send their nation's young people to study in Germany than elsewhere, thinking it a culturally "safer" environment. Additionally, after initially opting to emulate France's army, civil service and education system, or America's schools, Japanese reformers later turned to the German model in all of these areas. Unsurprisingly, German philosophies, theories and practices enjoyed commensurately greater currency in Japanese intellectual life than those of these other Western nations. German political economy, for example, encouraged a more statist economic model aimed at maximizing national power, with foreign policy successes substituting for domestic freedom, general prosperity or popular sovereignty as a source of legitimacy for the rulers.
Bernd regards the choice as a fateful one, setting the country on an undemocratic, imperial and militaristic course that led both Germany and Japan directly to the catastrophe of 1945, and the demise of that social structure they had sought to preserve.
As Martin owns, his research has some limitations--not least, his lack of access to Japanese sources, which is grounds for some caution. Additionally, Germany can hardly seem the sole foreign influence on the development of Japanese imperialism--this, after all, having been a period where this was the practice for every major power, even among much more liberal nations. Indeed, as a resource-poor island nation off the coast of Eurasia which built up a large navy and pursued colonies on the mainland, its situation evokes Britain much more than Germany--and the fact remains that Japan did emulate Britain when building up its navy (if only because Germany had virtually no navy to imitate until the late 1890s). Still, it is an interesting thesis with considerable explanatory power, not just for Japan's history over the last century and a half, but for what we see in its popular culture today, Germany's presence a legacy of that earlier period.