The line "He prayeth best, who loveth best" is the moral the Mariner learns from his supernatural journey. It echoes the theology of Augustine in Confessions, which Samuel Taylor Coleridge was very likely intentionally referencing in writing this poem. (Coleridge was a religious man very concerned with theology, even changing denominations of Christianity a few times in his life. An exploration of his collected notes also shows he was continuously reflecting upon his evolving belief system.)
The line referenced in the question makes more sense if it is read in its completed thought. The Mariner says:
He prayeth best, who loveth best
all things both great and small;
for the dear God who loveth us,
He made and loveth all.
Together, these lines make sense of the plot of the narrative while echoing Augustine's theological belief about the importance of loving all of God's creatures equally, even the lowest of them.
In Confessions, Augustine states:
The wicked are displeased by your justice, even more by vipers and the worm which you created good, being well fitted for the lower parts of your creation.
In other words, it is wicked to be "displeased with" any of God's creatures, even the lowest of creatures (vipers and worms). If you think about it, Biblically, snakes were cursed to go on their belly in the Garden of Eden, and worms are Biblically referenced in moments of death described. Since snakes have connotations of evil and worms connotations of death, it is not surprising why one may see them as lesser creatures. However, in Augustine's mindset, all creation is "good" because all creation was made by and called "good" by God in Genesis.
This theological perspective is exactly why the Mariner earns his curse by killing an albatross so flippantly. At first, his crew sees the killing of the albatross as something wicked because the wind that drives the ship fails when the albatross dies. However, when the fog clears, the crew changes their tune, celebrating the death of the albatross because the thick fog has lifted. Clearly, the crew bases their ideas of what is sinful or good upon how some action affects them. Perhaps their self-centered view of morality is why they end up suffering to the point of death while the Mariner stays alive.
This idea of valuing all of God's creatures is also why the Mariner must undergo such cruel and haunting penance, with the albatross hung around his neck as a symbol of his guilt. This theological view also explains why the Mariner's fortunes improve after he finally sees the beauty in creation toward the end of the tale. Of seeing the snakes, the Mariner says:
No tongue their beauty might declare: A spring of love gusht from my heart
and I blessed them unaware.
In this moment, the Mariner learns to love the "lowest of creatures"—a sort of sea-viper or sea-worm, if you will—and the curse is broken. He spreads this theological view around like a madman, but given his intense experience learning the lesson, it is not hard to imagine why.