When most people think about Dungeons & Dragons their minds will immediately go to your "stereotypical nerd," but that's not always the case.
The “stereotypical nerd” is the person who doesn’t really fit in with any particular crowd and that really doesn't have many friends. This person also lacks general social interaction with the general population. You can see examples of this trope in almost every modern television show from "Community" to "Futurama."
Not everyone who enjoys D&D is the typical over-zealous, middle-aged man who lives in his parent's basement; a lot of people play D&D for an escape from reality in role-playing someone other than yourself.
For example, in the campaign that I am currently a part of I am playing a chaotic good, arcane ranger. Now, for those of you who don't understand Dungeons & Dragons terminology and classes, a Chaotic Good person is someone who acts on their instinct but does things for the good of society. An arcane ranger is basically a nature warrior that makes use of arcane magic.
This character is somewhat like me just exaggerated a little bit. He is very snarky and sarcastic, which makes him a little bit of an asshole. He is guided by the drive to make magic a common practice which in this world is very restricted to practice.
While I personally am not spending my college days fighting for magic advocacy, but it is nice to be able to play as a character similar to myself that just has more freedom to do things.
Dungeons & Dragons is a game that can form a sense of comradery between friends and fellow gamers in the sense of accomplishing a task within the D&D campaign.
In this same campaign on a different realm, we recently killed the Evil Dragon Goddess Tiamant, which is a huge accomplishment for the characters in our party. This accomplishment was achieved through cooperation within the party and with the help of some supernatural elements such as other gods assisting the party to defeat the dragon goddess.
While all of these things are elements of Dungeons & Dragons, at its core D&D is a form of storytelling. A part of that storytelling does come from the Dungeon Master -commonly known as the DM- through the world that this person creates. Another part of this storytelling is through the characters backstories and the interactions that the characters have with one another.
On the backstories aspect of the storytelling within Dungeons & Dragons, the backstories really tell what the character's past was and how that past motivates the character in the current plot of the story that the DM has created. With my arcane ranger, his backstory is that his village was ransacked by a devastation beetle, which is basically a giant beetle that shoots acid. His village was destroyed and, somehow as an infant, he was the lone survivor. He was then picked up by an archer and a sorcerer who trained him in basic survival and magic skills to become who he is currently in the campaign.
Storytelling within character interactions is different than the backstories of the characters. For one thing, this form of storytelling is currently happening within the campaign and anything your character says can affect that drastically. Everything said during a D&D session affects the outcome of your character and of the game.
With this arcane ranger, he has fallen in love with a snarky Knight who is very much like him. Their interactions have developed throughout their adventure and they somehow got along. If, say, the arcane ranger said something outlandish or the knight said something of the sort, their relationship could have changed and they would have had to deal with the ramifications of that.
As such storytelling has a lot to do with D&D in such a way that it adds to the enjoyment and role-playing aspects of the game for the individual players.