The question implies that breastfeeding is an unpleasant and inconvenient thing that should be put up with as long as possible to give a baby "enough" benefit, at which time the box can be ticked and everyone can stop. However most families that nurse past 6 months find it a convenient and pleasant thing, so there's no particular pressure to stop.
The Canadian government, in conjunction with the medical association, recommends exclusively breastmilk for 6 months, and a mix of "real food" and breastmilk after that up to age 2 or longer. The "or longer" part is typically determined by how nursing is working for that particular family.
Here is a whole paragraph of studies and sources from that page:
Breastfeeding beyond six months has been associated with a number of positive infant and maternal health outcomes. Breastfeeding longer, in addition to a wide range of other determinants, may have a protective effect against overweight and obesity in childhood (Arenz, Rückerl, Koletzko, & von Kries, 2004; Scott, Ng, & Cobiac, 2012; von Kries et al., 1999). Limited evidence suggests breastfeeding continues to provide immune factors during the first and second years (Goldman, Goldblum, & Garza, 1983; Goldman, Garza, Nichols, & Goldblum, 1982). An observational study suggests breastfeeding to 12 months may protect against infectious illnesses, particularly gastrointestinal and respiratory infections (Fisk et al., 2011). Findings have consistently shown a decreased risk of maternal breast cancer with longer durations of breastfeeding (Collaborative Group on Hormonal Factors in Breast Cancer, 2002; Chang-Claude, Eby, Kiechle, Bastert, & Becher, 2000; Brinton et al., 1995). Limited evidence also suggests a protective effect for the breastfeeding mother against ovarian cancer (Luan et al., 2013; Su, Pasalich, Lee, & Binns, 2013; World Cancer Research Fund & American Institute for Cancer Research, 2013). Mothers who breastfeed their older infants and young children also report experiencing an increased sensitivity and bonding with their child (Britton, Britton, & Gronwaldt, 2006; Fergusson & Woodward, 1999; Kendall-Tackett & Sugarman, 1995).
I recommend not trying to decide before birth how long the baby will nurse. After age 1 it's not only up to the mother, and it's possible a toddler will wean even though the family had planned to keep providing breastmilk for some time more. Committing to "at least 6 months" is probably the best strategy to start with.