After the soulless husk of Sirius Black was executed by the Ministry, Hermione was one of the few who went with Harry to his funeral. In gratitude for her ongoing support, and in recognition of her love of helping house-elves, a month or so later he gifted her with one he’d inherited. Kreacher had held no love for Harry, but quickly became devoted to Mistress Hermione.