Which relationship aspects are meant with this idiom, is it some specific irony?
He that spareth his rod hateth his son: but he that loveth him chasteneth him betimes. Proverbs, 13:24
Of course now it mostly used as hard irony, the society condemns both aggressor and victim for such thoughts. It does not really mean hitting, it can be about psychological pressure.
Also it used humorously when boys with puberty just started can't express their new attention to girls other ways than to harass them (not in some really bad way).
It's an old 'wisdom' about a husband: hopefully, this way he reveals (from the depth of his soul) he's not indifferent to his wife (is jealous at least). Maybe it is possible to use the phrase for expressing irony about something (as a remark about beating someone or even something), but it happens not too often.
I think it means that the husband beats his wife trying to 'bring to reason' or 'teach her' in any way. Or as Alex_ander said, he is not indifferent to her. And therefore he 'loves' her in a way. And this idiom reflects the ironical view on a 'traditional' patriarchal family, where husband 'owns' his wife and has moral rights to abuse her.
Nowadays it isused as an irony only.