Dark chocolate has cocoa flavanols which are a class of flavonoids. Flavonoids are integral to cognitive function and the cocoa flavanols in dark chocolate have been shown specifically to improve cognitive function (Desideri et al., 2012; Mastroiacovo et al., 2015). Dark chocolate with higher cocoa percentages provide more of these flavanols and usually has less sugar.
Sources