When the main character (protagonist or otherwise) is a Lone Wolf or a Loose Cannon that Works Alone, they can appear strong and lonely and often very angsty, but often don't come across as very relatable. The simplest explanation for this is just that humans are social creatures in general, and even the 40% of the human population that's introverted tends to like having a friend they can trust to support them when things get tough.
Besides, how many TV shows, movies, animated shorts, video games, or children's stories have you seen where the moral of the thing is that "it's okay to ask for help when you need it" or "when you can't do it alone, your friends are there to help you!"
And so we come to the Best Friend. This character goes beyond the functional companion or brother at arms to something more like a wing-man or the ally you can trust to keep all your secrets, even under torture.
This is characters like; Ron Weasley from the Harry Potter series (see Harry Potter and The Goblet of Fire for a good example), F'nor from the Dragonriders of Pern series and especially in Dragonquest, or Pikachu in just about any season of Pokemon where Ash is the main character.
It's not uncommon, especially in TV shows (and double that for anime), for the Best Friend to initially dislike the main character. This contrast between how they treat each other in the first few episodes and how close they are later on when the main character wins them over one way or another impresses on the viewer that the main character is the kind of person who's either really good at making friends or who has an especially prominent need for them.
In books, as with Harry Potter, you'll see the main character and Best Friend grow close, then have arcs where they disagree or get angry at each other and, for one reason or another, aren't friends anymore for a while. (This happens in TV shows also, but it's usually resolved so quickly that it leaves little impression on me.)
The main purpose of the Best Friend is two-fold:
1. To be a foil for the main character, being strong where they're weak or smart where the MC is ignorant. This is similar to how the Love Interest is portrayed, and there's understandably a lot of overlap in how the two relationships pan out, both in fiction and in real life. (Ship wars have been started over less.)
2. To be the support in the Darkest Hour, either sticking with the MC through the really bad times or coming to the rescue after realizing that deciding to not be friends with someone over something as superficial as not being as popular as the other guy is pretty dumb.
The Best Friend is often given characteristics like unfailing loyalty or a strong moral compass to direct the main character to the "right thing to do." (A blend of the Best Friend and Rebel character types might be the opposite, with the MC being the moral compass.)
Possibly my favorite Best Friend character is Sokka from Avatar: The Last Airbender. At first he's suspicious and grumpy, but in the space of 2-3 episodes, he's best buddies with Aang and later becomes "the idea guy" (Mastermind) for the group, concocting an endless stream of crazy ideas that gradually become more and more applicable as he matures and learns more about himself. (He's also the Everyman character in a group of super-powered weirdos, so he's kinda like the Batman to their Justice League. Only with less money.)
To the previous Element
To the next Element