Deuteronomy 21 verse 15:
כי-תהיינה לאיש שתי נשים, האחת אהובה והאחת שנואה, וילדו-לו בנים, האהובה והשנואה; והיה הבן הבכור, לשניאה
This is translated, incorrectly, as
If a man has two wives, and he loves one but not the other, and both bear him sons but the firstborn is the son of the wife he does not love (New International Version);
Fortunately, the King James version has it right, with:
If a man have two wives, one beloved, and another hated, and they have born him children, both the beloved and the hated; and if the firstborn son be hers that was hated:
The Gemara asks how is it possible that a husband's feelings towards his wife might be of such interest to God, that he needs to rely on it to rule, one way or the other, about the status of the sons? Rather, the meaning of the verse must be that the wife is beloved or hated to God - and that is measured by the type of marriage. If it's a marriage condoned by the rules, it is blessed and the wife is loved; if it's a forbidden marriage (e.g incestuous or other) it is not, and the wife is unloved (though the status of the son, in this matter, is unaffected).
This thread began, and is explained, here.