The practice in ancient times was to provide some compensation to a healer in the form of cattle or other goodies as they provided medicine or treatment for any ailments. While the healer's gift was most times considered god-given, others were trained by previous healers and this was their livelihood and profession. They may not have all considered compensation as necessary and hence most satisfied clients would provide food or cattle as a token of gratitude. One that was known to compensate (well) or show their gratitude would find that the healer would prioritize them and work more diligently for their treatments. This led to our ancestors realizing that paying for a service is similar to providing it.
The proverb is used to highlight the importance of compensation (or showing gratitude) for goods and services well provided. Paying for work or services provided ensures good quality work.