I understand the worry, but you are focusing on the wrong thing in my opinion.
Your daughter is who she is. We all hope for ideal conditions in which our children can flourish, but realistically part of the reason some children achieve certain things, and others struggle more , is that they are more capable of filtering out external influences and focus on their own goals.
There are parents who intentionally stifle their children's freedom to live as they would choose to, by having a stricter parenting style, but this option isn't risk free.
Your daughter's emotional maturity level will determine how capable she is to make decisions at the moment which will impact on her future. School exams partially reflect intelligence, but there will be plenty of clever children who choose to not study for whatever reason, and the results of said exams will be on par with less capable, but more dedicated students. That's life.
You know the best approach to take with your daughter but this other "friend" is simply part of life, in the same way that she might have had a set back for any number of reasons, at this stage in her life.
You can help her achieve certain exam results, if she is willing, by helping organise her study sessions, or even possibly getting someone( you, relative, tutor) to go through work with her, but at the end of the day, if she needs help with self esteem, then working on this will be more beneficial in the long run, and will help her in all aspects of her life.