It’s funny that you would ask this question in English, because English as one of the closest relatives of German holds the clue to the answer. Let’s look at the translations a few centuries back, before it became customary to address everyone in the plural in English. And let’s put Middle Dutch in between as it’s so closely related to English and German and in some respects between them:
- ich = ic = I
- du = du = thou
- er/sie/es = hi/si/het = he/she/it
- wir = wi = we
- ihr = ghi = ye/you
- sie = si = they
(Before someone protests thinking I made a stupid mistake: Of course in modern Dutch, du has been replaced by jij/gij just like thou in English has been replaced by you; and plural jij/gij has been replaced by jullie = ju lieden (you people), just like English has recently started the process of replacing plural you by you guys, you all or even yous[e].)
- mir = mi = me
- dir = di = thee
- ihm/ihr/ihm = hem/haer/hem = him/her/it
- uns = ons = us
- euch = u = you
- ihnen = hem/hen = them
I think from these lists it is clear that apart from various changes caused by addressing single people in the plural for politeness, basically all these personal pronouns are cognates, i.e. they were once the same words but have undergone certain shifts of pronunciation and sometimes meaning. (One really needs to check this by looking at even earlier stages, but this checks out - with some exceptions, see comments.)
It follows that the homonymy you noted in German is an accidental result of convergence:
- 2nd person plural nominative ihr corresponds to Middle Dutch ghi and English ye/you.
- 3rd person singular feminine dative ihr corresponds to Middle Dutch haer and English her.
The case of 3rd person singular feminine dative ihr is very straightforward given the great similarity of ihr, haer and her.
According to Etymonline and the DWDS source provided by falkb, this is what happened in the much more interesting case of the 2nd person plural nominative pronouns:
Apparently there was a Proto-Germanic ancestor similar to Gothic jus and English you. (And, remarkably though probably by coincidence, even more similar to the recent English innovation yous[e].) In the West and North Germanic languages (i.e. in all Germanic languages other than Gothic), the vowel of this pronoun was assimilated to the vowel of the corresponding first person pronoun. This is how English got ye (analogous to we) as a variant of you, and how the various other North Sea Germanic languages got ji (from wir). (I am restricting this statement to the North Sea Germanic languages because in the other North and West Germanic languages apparently this happened too early to leave any records.)
Presumably because ji is a bit funny to pronounce, there seems to have been a tendency to either replace j by g or drop it entirely. In the case of German and also the Nordic languages this must have happened very early, because both this vowel change and the subsequent addition of a final r, again by assimilation from the corresponding first person pronoun, was already completed in Old High German (wir, ir) and in Old Norse (wer, er).
Ihr = haer = her is simply the same word and didn’t undergo many changes.
The story of the second person plural nominative is much more interesting. It started with something similar to Gothic jus (or in fact the recent English yous[e]). In English it temporarily got the variant ye by assimilation with we. In the other Germanic languages (North and West Germanic, i.e. excluding Gothic), first the vowel was assimilated in the same way, resulting in ji, and then in Old High German and Old Norse the word even got the final r of wir. (Dutch, like English, didn’t participate in this last step.)
Anyone interested in this question might be interested in Stephen Howe's thesis on Germanic pronouns. Unfortunately it's not available online (and I have only read a review), but a related paper on North Sea Germanic Pronouns is available for free. Note that this doesn't cover German but does cover ancestor languages of Dutch and of the northern German dialects.