It's much easier NOT to think of Dungeons and Dragons as a game.
There's no winner, no predefined goals, and no rules that the DM can't change. As if that weren't enough, there are no limits on what you can try to do during your turn (and often no defined turns at all)! In order to understand the appeal of Dungeons and Dragons, I find it best to throw out all preconceived notions of it as a "game" and start anew.
Dungeons and Dragons is an experience where you journey to another world to live the life of someone else. One person takes on the role of the Dungeon Master or Game Master and the other people get the much less cool name of players. Simply put, it's the Dungeon Master's job to create a universe with enough detail and believability that the players truly feel they are there. It's the players' job to live in that universe and make decisions that will affect what happens to them.
99.99% of the time the players take on alternate identities called characters. Your character is your identity in the universe where the game takes place. The goal of creating a character is to describe them well enough that they seem to take on a life of their own. For example, if you can imagine how your character would react to situations like being threatened by drunkards in a bar, talking to a dragon sitting on a pile of treasure, or finding an artifact that can resurrect the dead, you've literally "breathed life into them." At this point, you are ready to take on their identity to face whatever challenges might arise before them. In other words, you are ready to write their story.
D&D is an open-ended game. You could be spying on the enemy while posing as one of their soldiers, leading a revolution against a corrupt king, escaping from a dungeon where you were wrongly imprisoned, or rescuing a farmer's daughter from a vampire's mansion. If you can imagine it, it can happen. It's the Dungeon Master's job to immerse you in the fantasy world and tell you the results of your actions, so there's no limit to what you can attempt to do. The DM might have to think awhile after you tickle a sleeping werewolf, or tell you that you fail to pick the dungeon lock with the dagger you always keep in your boot, but that doesn't stop you from doing it.
Here's a quick sample situation:
DM: 'You are alone in a forest, surrounded by trees that appear to be
hundreds of years old. Many beams of light shine through the
canopy onto moss still covered with tiny droplets from the
recent rain. Birds are singing overhead, but you only manage to see
them when they fly from one branch to another. The power of nature permeates
this peaceful sanctuary, unconcerned with the passage of time.
As you were admiring the scene, an arrow breaks you out of
your reverie as it thuds into a tree a few feet from your head. As you
turn around, you see a young but stout-looking elf staring at you
with another arrow already set to his bow. "Why do you trespass upon
Llanowar Territory? We don't take kindly to strangers, and unless you
can tell me your business here you'd better get a head start in
your race with my next arrow." he says, with his eyes trained on
you like a cat's on a mouse.'
Now, if I've done my job properly, at least a tiny part of you feels like you are actually standing in a forest facing an unyielding elf.
Here comes your part: what do you do? Tell the elf you were lost and plead his forgiveness? Strike him down with a bolt of lightning for his impudence? Say you will leave peacefully if you are permitted to ask a few questions about your brother who went missing 4 days ago? It's all possible, and what happens next is entirely up to you.
What's with all the dice, then?
Technically I've been describing a class of games called roleplaying games1, of which D&D is the most well known. Almost all roleplaying games follow the basic structure I've just described, but they vary greatly in the setting and the rules used to resolve your actions. Games can happen in the Star Wars universe, World War II, the Cthulhu mythos, you name it. Each game usually has one book for the rules and several others that cover the setting and material to use in adventures. For this post, I'll just give you a whirlwind tour of the basic D&D rules.
In D&D, nearly everything you do corresponds to a certain skill. Each character will have the various skills recorded on a character sheet, along with numbers that indicate their level of proficiency. Games can have anywhere from 2 (mental and physical) to over 50 different skills, ranging from musical performance, to historical knowledge, to animal handling, to sleight-of-hand.
Note I'm using D&D 3.5e for specific examples, it will vary per edition of the game.
Here's a quick example of how the different levels of strength might break down:
- +12: Incredibly strong. Lift 300 pounds and bend iron weapons with bare hands. [Barbarian King]
- +9: very strong. Lift 250 pounds and move small boulders. [Powerful Warrior]
- +6: strong. Lift 200 pounds and carry a 50 pound pack for an entire day. [Able Adventurer]
- +3: somewhat strong. Lift 150 pounds and pull a cart with a small load. [Anyone with training]
- +0: average: Lift 100 pounds and move most furniture without help. [Untrained]
- -3: weak: Can't lift 100 pounds or carry average loads. [Delicate Royalty]
(Those values are highly debatable and the scale is probably off, but this is just a quick demonstration.)
In addition, every task has an assigned difficulty level or difficulty class, abbreviated DC. To determine if a character succeeds at a task, they roll a 20-sided die, or a d20. This is called a check or skill check. They only succeed if the number they rolled plus the bonus they have for the skill is at least equal the task's DC. Hence, an incredibly strong character will be able to achieve a strength-related task of average difficulty 100% of the time because even if they get the lowest possible result of 1, 1+12 is still greater than the DC 10 that corresponds to average difficulty. A weak character on the other hand would have to roll a 13 or greater to succeed at or pass a DC 10 strength check because their strength modifier is -3 instead of +12. Thus, a weak character would succeed at a strength-related task of average difficulty only 40% of the time, while an incredibly strong character would succeed 100% of the time.
Here's some example strength-related tasks:
DC 0 (Very Easy): Throw a pillow across the room.
DC 5 (Easy): Jump over a fallen tree.
DC 10 (Average): Kick down a weak wooden door
DC 15 (Tough): Climb onto a roof while dangling from the side.
DC 20 (Challenging): Roll a small boulder uphill.
Some extremely difficult tasks may have DCs that are over 20. For a task with DC 29, a very strong character (+9 bonus to strength) would still only have a 5% chance of success as they need to roll a 20 to be >= the DC. A character with a +8 bonus or less would have no chance at all of succeeding. An example of a DC 29 check might be leaping across a 30-foot chasm.
As to the pieces, during combat the terrain is divided into a grid of squares, with one character or enemy occupying each. During your turn in each round of combat, you can move around a certain number of squares and perform at least one action (usually an attack), after which the next player or enemy takes their turn and does the same. You'll often see the game played with elaborate miniatures because they enhance the reality of the game.
That's the basic foundation that just about everyone uses. There are many more rules that cover making characters, leveling up from gaining experience, resolving combat, and many other areas, but I'm going to let you in on a little secret: nobody follows all of them to the letter. Okay, some people probably do, but since D&D is rarely played competitively, the group is free to bend the rules or invent their own in order to make the game more fun. As a consequence, there's an old saying that if you ask 10 people how to play D&D, you'll get 10 different answers.
While this answer definitely exhibits my own bias of prioritizing story over rules, hopefully I've been able to convey enough about the nature of roleplaying games to satisfy your immediate curiosity. Feel more than free to ask for clarification in the comments or ask a new question entirely. We'd love to help!
1. often referred to as pen and paper or tabletop roleplaying games to distinguish them from roleplaying video games