"Among primates, the function of the bared-teeth also has different meanings depending on the species and their type of social organization. Among macaques species that have despotic social systems characterized by strict, linear dominance hierarchies, i.e. rhesus monkeys, the bared-teeth display appears to be a signal of submission, or rank recognition in that it is only given by subordinates to higher ranking individuals (van Hooff, 1976; de Waal and Luttrell, 1985). This expression has been referred to as a formal signal of dominance in the rhesus monkey because it is highly ritualized in appearance and has long-term predictability in determining dominance relationships despite short-term variation in social contexts (de Waal and Luttrell, 1985). In this study, bared-teeth displays performed by subordinate individuals occurred most often in response to the approach of a dominant monkey, and the most frequent response was for the subordinate to withdraw from any social interaction (de Waal and Luttrell, 1985). However, the meaning of the bared-teeth display is quite different when used by species with more egalitarian social systems, including some macaques, mandrills, Gelada baboons and chimpanzees (van Hooff, 1967; Preuschoft and van Hooff, 1997). In these species, the bared-teeth display is more appeasing and functions to increase social attraction and affiliation. It communicates benign intent in that the signaler wishes no harm, and that there is no risk of aggression (van Hooff, 1967; van Hooff, 1976; Waller and Dunbar, 2005). It can also occur during affiliative contexts, such as grooming, sexual solicitation and reconciliations, and thus functions to increase affiliative tendencies and reduce proximity between individuals (van Hooff, 1973; Preuschoft and van Hooff, 1997; Parr et al., 2005; Waller and Dunbar, 2005)."
>https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2555422/tl;dr It's a form of showing submission and that that they wish to show no aggression