Marilla is talking to Anne about how she has noticed that Anne did not say her prayers the night before. Anne tells Marilla that she has chosen to not pray because she was taught that God made her hair red on purpose.
Marilla recognizes that Anne is "a girl who knew and cared nothing about God's love, since she had never had it translated to her through the medium of human love."
Later in the book Anne expresses that she feels gratitude for the beauties around her, she shows love for the people in her life and she also expresses how easy it us for her to pray. It doesn't really state it this way, but I think Anne has learned what love feels like and she so she is able to easily express it to others, and to God.
So back to the purpose of charity. I think that one reason that we are commanded to love others is that as others feel our love, they better understand God's love, because our love truly is rooted in God's love for his children. As we show pure love for others, we can help them come to know Jesus Christ and HEavenly Father.