This is the story of Shabari, Rama and the half-eaten berries, from the epic Ramayana, a little in detail..
Shabari, an elderly ascetic, was an ardent devotee of Rama. When Rama was in search of his beloved wife Sita, he passed through the village where Shabari lived, where she had been eagerly waiting to meet him and get his darshan.
In anticipation of his visit, she collected berries from the forest to offer to Rama. To ensure that he got only the sweetest of berries to eat, she plucked and tasted each individual berry, and only if the berry was sweet, would it be collected by her!
When she finally got the opportunity to meet Rama, Shabari offered him the half-eaten berries, which he graciously accepted and ate with a lot of relish, much to the shock of the sages around him. They considered eating someone else's leftover food as 'impure'. Rama further explained to them that it was only sheer devotion that he considered to be the purest, way above everything else!