The phrase "this was a favor to you" means that the action or gesture in question was done as a kind or helpful act specifically for the benefit of the person being addressed. It implies that the speaker went out of their way to help or assist someone, possibly as an act of goodwill, even if it wasn't necessary or required.
Comparison to "Do me a favor":
"This was a favor to you": Focuses on something already done, emphasizing that it was an act of kindness or assistance.
Example: "I helped you move last weekend. This was a favor to you."
"Do me a favor": A request for help or assistance.
Example: "Do me a favor and pass me that book."
The two phrases differ in tense and context but are related in meaning because they both involve the idea of helping or doing something for someone.