Sheaf cohomology and injective resolutions
Since everybody else is throwing derived categories at you, let me take another approach and give a more lowbrow explanation of how you might have come up with the idea of using injectives. I'll take for granted that you want to associate to each object (sheaf) $F$ a bunch of abelian groups $H^i(F)$ with $H^0(F)=\Gamma(F)$, and that you want a short exact sequence of objects to yield a long exact sequence in cohomology.
I also want one more assumption, which I hope you find reasonable: if $F$ is an object such that for any short exact sequence $0\to F\to G\to H\to 0$ the sequence $0\to \Gamma(F)\to \Gamma(G)\to \Gamma(H)\to 0$ is exact, then $H^{i}(F)=0$ for $i>0$. This roughly says that $H^{i}$ is zero unless it's forced to be non-zero by a long exact sequence (you might be able to run this argument only using this for $i=1$, but I'm not sure). Note that this implies that injective objects have trivial $H^{i}$ since any short exact sequence with $F$ injective splits.
Now suppose I come across an object $F$ that I'd like to compute the cohomology of. I already know that $H^{0}(F)=\Gamma(F)$, but how can I compute any higher cohomology groups? I can embed $F$ into an injective object $I^{0}$, giving me the exact sequence $0\to F\to I^{0}\to K^{1}\to 0$. The long exact sequence in cohomology gives me the exact sequence $$0\to \Gamma(F)\to \Gamma(I^{0})\to \Gamma(K^{1})\to H^{1}(F)\to 0 = H^1(I^{0})$$
That's pretty good; it tells us that $H^{1}(F)= \Gamma(K^{1})/\mathrm{im}(\Gamma(I^{0}))$, so we've computed $H^{1}(F)$ using only global sections of some other sheaves. We'll come back to this, but let's make some other observations first.
The other thing you learn from the long exact sequence associated to the short exact sequence $0\to F\to I^{0}\to K^{1}\to 0$ is that for $i>0$, you have $$H^{i}(I^{0}) = 0\to H^{i}(K^{1})\to H^{i+1}(F)\to 0 = H^{i+1}(I^{0})$$
This is great! It tells you that $H^{i+1}(F)=H^{i}(K^{1})$. So if you've already figured out how to compute $i$-th cohomology groups, you can compute $(i+1)$-th cohomology groups! So we can proceed by induction to calculate all the cohomology groups of $F$.
Concretely, to compute $H^{2}(F)$, you'd have to compute $H^{1}(K^{1})$. How do you do that? You choose an embedding into an injective object $I^{1}$ and consider the long exact sequence associated to the short exact sequence $0\to K^{1}\to I^{1}\to K^{2}\to 0$ and repeat the argument in the third paragraph.
Notice that when you proceed inductively, you construct the injective resolution $$0\to F\to I^{0}\to I^{1}\to I^{2}\to\cdots$$ so that the cokernel of the map $I^{i-1}\to I^{i}$ (which is equal to the kernel of the map $I^{i}\to I^{i+1}$) is $K^{i}$. If you like, you can define $K^{0}=F$. Now by induction you get that $$H^{i}(F) = H^{i-1}(K^{1}) = H^{i-2}(K^{2}) = \cdots = H^{1}(K^{i-1}) = \Gamma(K^{i})/\mathrm{im}(\Gamma(I^{i-1})).$$
Since $\Gamma$ is left exact and the sequence $0\to K^{i}\to I^{i}\to I^{i+1}$ is exact, you have that $\Gamma(K^{i})$ is equal to the kernel of the map $\Gamma(I^{i})\to \Gamma(I^{i+1})$. That is, we've shown that $$H^{i}(F) = \ker[\Gamma(I^{i})\to \Gamma(I^{i+1})]/\mathrm{im}[\Gamma(I^{i-1})\to \Gamma(I^{i})].$$
Whew! That was kind of long, but we've shown that if you make a few reasonable assumptions, some easy observations, and then follow your nose, you come up with injective resolutions as a way to compute cohomology.
Even though I'm far from a historian, it seems to me the initial reason for considering injectives is
-prior to derived categories;
-but comes later than the task of extending left exact functors.
For the latter, in particular, there are apparently many ways of doing it. But:
injective resolutions are almost ideal for comparing different definitions of cohomology.
It is important to note that cohomology was around before injective resolutions, appropriate to different situations, and then the question came up of comparing several of them when they all made sense. As a concrete example, you might consider Cech and De Rham cohomology on a smooth manifold, both with real coefficients. It's also obvious that cohomology was not initially thought of in terms of the failure of exactness, which, in any case, can be good or bad depending on the situation.
Typically, you have two complexes A and O with rather different constitutions. How do we then compare their cohomology? The standard method is to find a third one C that admits natural maps A->C and O->C. Then we proceed to show that both of these induce isomorphisms on cohomology. A very basic form of this argument occurs even when showing that the cohomology computed using triangulations is independent of the triangulation. There, C is the complex associated to a common refinement.
Even in other situations, it makes sense to consider C as a 'common refinement' of some sort. The point then, is that an injective complex gives an ultimate common refinement in a wide variety of situations. This is because injectives, by their very definition, receive maps (more precisely, map extensions) very easily, so that you don't need to cook up a separate C for each pair of A and O. Once the injective definition is around, the different comparisons can be made in one fell stroke with the theorem that all acyclic resolutions compute the same cohomology as the injective one. Of course, `acyclicity' here can only be defined in terms of the fixed definition using injectives, and checking for it can be tricky and situation-dependent. For example, checking that the Cech resolution is acyclic on a variety requires that the covering consist of affines, and then knowledge of some property of affines. Checking that the smooth differential forms on a manifold form an acyclic requires some technicalities on partitions of unity and extensions of C-infinity functions, and so on. (Of course such verification processes are routine, once you're used to them. But whenever they are examined afresh, they always strike me as quite technical in interesting ways.) In the end, however, it's clear that this approach brings considerable conceptual unity to the ubiquitous problem of comparing cohomology. It's my best guess at the real initial motivation behind the definition.
You might even say that the definition of an injective object incarnates purely wishful thinking with regard to the problem of comparisons. What could be more naive than thinking there is one thing that frees you at once from all future specific consideration of C? The deep insight is that objects realizing such wishful thinking do exist often enough in nature. If I may add a bit of philosophical reflection, the definition of injectives illustrates quite well the sense of child-like innocence that Grothendieck regarded as fundamental to his mathematical nature. Several people have commented on the meaning of Grothendieck's self-evaluation, especially in view of the apparent sophistication of the resultant technology. It is interesting to identify the precise mathematical locus of such innocence, if only to gain some sense of when innocence is likely to yield fruit.
This is an interesting discussion to someone raised in the 60's. It illustrates how lack of motivation creeps into books unnoticed. Back when Hartshorne was being written everyone was steeped in the then standard derived functor formalism of Cartan Eilenberg and Grothendieck, axiomatizing constructions of cohomology via complexes. So the pattern of this formalism explained so nicely by Anton and Andrew above was taken for granted. As the subject evolved, it was understood that acyclic resolutions could replace the more categorically natural injective ones. This is the gist of Evan's answer. Perhaps also there is a tradition in mathematics books of giving definitions without historical background. I have always had difficulty with any unmotivated definitions, such as abstract "residues" and modern Riemann Roch theorems, so I keep stressing to my students the value of learning the original version of Riemann, even if their goal is to understand cohomological and arithmetic versions. Anyway, excellent question.