The one completes the other.
Rather than presenting the institution of marriage in a manner that would celebrate it, the Torah creates the institution in the context of a scenario that features repeated failed marriages.