The question is too broad, so the answer is "It depends".
Sadagheyani, H.E. and Tatari, F. (2021), "Investigating the role of social media on mental health", Mental Health and Social Inclusion, Vol. 25 No. 1, pp. 41-51. DOI: 10.1108/MHSI-06-2020-0039
This study was a systematic review that looked at the literature as of 2020:
The findings showed that social media has negative and positive effects on mental health. Negative effects included anxiety, depression, loneliness, poor sleep quality, poor mental health indicators, thoughts of self-harm and suicide, increased levels of psychological distress, cyber bullying, body image dissatisfaction, fear of missing out and decreased life satisfaction. Positive effects included accessing other people’s health experiences and expert health information, managing depression, emotional support and community building, expanding and strengthening offline networks and interactions, self-expression and self-identity, establish and maintain relationships.
Berryman, C., Ferguson, C.J. & Negy, C. Social Media Use and Mental Health among Young Adults. Psychiatr Q 89, 307–314 (2018). DOI:10.1007/s11126-017-9535-6
Some studies have indicated that social media use may be tied to negative mental health outcomes, including suicidality, loneliness and decreased empathy. Other studies have not found evidence for harm, or have indicated that social media use may be beneficial for some individuals.
This particular study showed:
social media use was not predictive of impaired mental health functioning. However, vaguebooking was predictive of suicidal ideation, suggesting this particular behavior could be a warning sign for serious issues. Overall, results from this study suggest that, with the exception of vaguebooking, concerns regarding social media use may be misplaced.
For balance, here is another study that showed that, as Facebook was rolled out in colleges, mental health declined:
Braghieri, Luca, Ro'ee Levy, and Alexey Makarin. 2022. "Social Media and Mental Health." American Economic Review, 112 (11): 3660-93. DOI: 10.1257/aer.20211218
We find that the rollout of Facebook at a college had a negative impact on student mental health. It also increased the likelihood with which students reported experiencing impairments to academic performance due to poor mental health. Additional evidence on mechanisms suggests the results are due to Facebook fostering unfavorable social comparisons.
(This was a "natural experiment", and I can't see how they accounted for exposure to social media increasing people's awareness of mental health issues, the relative health of their cohort and the available resources, and thus increased reporting of mental health issues without increasing the prevalence.)
Meanwhile adolescents think it is bad for mental health:
Michelle O’Reilly et al, Is social media bad for mental health and wellbeing? Exploring the perspectives of adolescentsClinical Child Psychology and Psychiatry, Volume 23, Issue 4 doi.org/10.1177/1359104518775154
This 2018 study based on focus groups found:
Thematic analysis suggested that adolescents perceived social media as a threat to mental wellbeing and three themes were identified: (1) it was believed to cause mood and anxiety disorders for some adolescents, (2) it was viewed as a platform for cyberbullying and (3) the use of social media itself was often framed as a kind of ‘addiction’.
Maybe the negatives are outweighed by the positives - using social media programmes to educate people and improve their mental health.
Does that work? Cochrane has a systematic review on the subject. Short answer: No, the evidence doesn't support it!
Mental health is a huge area. Youths and adolescents are a big group, covering a range of ages. Social media is a broad term.
There is no single answer to the question.