This is actually an interesting little story.
Old Japanese, as far as we can tell, didn't have a dedicated subject marker - if you wanted a subject that wasn't the topic also, you just left it unmarked. It had two genitive particles, though, *nə and *ŋga (modern の and が); which varied according to a kind of animacy hierarchy - *ŋga with personal pronouns and names IIRC (I've forgotten some of the details), *nə with the rest.
However, like several nearby languages that have this kind of relativisation-through-adnominalisation strategy (where relative clauses look like main clauses with different verbal morphology), the subjects of relative clauses could be marked as genitive. (Korean and Turkic both do/did this IIRC, Mongolic and/or Tungusic might.) This seems to be a reflection of the fact that noun clauses and verb clauses share some interesting structural similarities, especially crossover between subjects and possessors - compare English 'I don't like his having done that'.
Over time (starting around the Old > Middle Japanese transition IIRC), people reanalysed subject genitives inside relative clauses as just subject markers, and started using them within main clauses as well. The Ryuukyuuan languages have mostly stopped here, and maintain the dual use of reflexes of *nə and *ŋga in both subject and possessor functions. Mainland Japanese further reduced was now が to only marking subjects, and restricted what was now の to only marking possessors.
This case is the exception to that split. It's not clear whether it's a simple retention from earlier times or instead a further example of subjects and possessors patterning alike, and it's probably both.
(Yaeyama IIRC is an example of a Ryuukyuuan language that doesn't have an animacy hierarchy in subject markers, but it doesn't mark subject or object at all and leaves role marking to word order.)