means that
a reasonable settlement may be preferable to costly litigation when a dispute can be resolved fairly by agreement.
Imagine a case where legal costs are high so it is the best to agree with your opponent instead of settling a dispute in court.; then “Agree, for the law is costly” fits well.