So this is a very old expression. Dates back to the 1500s. It's literal meaning refers to how flies will get stuck in honey and stay away from you (a good thing).
The human relationship meaning refers to how you treat people. Treat them with sweetness (kindness, compassion, consideration) and you don't have as many problems (flies bothering you). Treat them nasty (vinegar) and your problems will never go away.