Landmark judgment shows a careful investigation into individual family circumstances must be done to ensure agreements benefit the children in divorce cases