In improvisational music, like jazz for example, the musicians will play a song that has been composed in advance, but by choice they go "off-script" and, cooperatively, make their very own creation in the moment, guided by the structure of the composition but nevertheless doing something distinctly new with each performance. In order to do this well, and create something of beauty that actually sounds good, jazzers need to have a solid understanding of how and what to play; in a word, they need to know what moves make sense, among the essentially infinite possibilities that are available to them, within the musical context that they're in. Far from being "mere" players of the music, they are composing on the spot.
Something similar - though different in important ways - happens when two players sit down to play a game of chess. The most notable difference of course is that here, unlike the musical setting, the play is competitive rather than cooperative. That is why there comes a point in every chess game where one is forced to improvise. You can try coming in with a pre-composed script that you want to play, but your opponent most likely isn't going to play along. Each player will have to compose his or her half of the game on the spot.
You can think of a chess opening that has its own name and well-known variations much like a good song with its musical score. Through much playing, it has stood the test of time (both on the White side and the Black side) and is recognized as something of worth. In this sense, such openings are a good thing for a chess player to become familiar with. (Consider this: would you rather listen to music made by someone who's already absorbed a lot of other music, or someone who's never heard any before?) But just as someone who has done nothing but memorize the scores of a few good songs would be at a loss if asked to compose a great new piece, a chess player who has focused too much on memorizing opening lines will continually run into points where he's at a total loss as to what to do.
In each case - the composer and the chess player - what is truly useful for future performance is to seek an understanding as to what makes the individual components of a song/opening good or bad, and how they fit together to work toward a common goal, be it an aesthetically pleasing piece of music or a won game of chess. To make one's own worthwhile creations, it is more important to know how to find one's own way than just to know what others have done in the past. But the latter kind of knowledge can definitely help with the former, as long as one focuses on the ideas and principles underlying the moves, rather than just the moves themselves.
As an addendum, here is an illustrative example of how not to use book knowledge in one's games. During a 1988 tournament, a strong GM was about to have a game as Black, and was skimming through the latest Informant for some up-to-date theoretical information. There he found a game in the Petroff Defense, in which Black managed to secure a draw, that featured what was listed as a theoretical novelty (TN) on move 5 for Black. Without thinking much about the value of the move, our intrepid GM decided to give it a go himself. The game played out so:
[White "Alonso Zapata"]
1. e4 e5 2. Nf3 Nf6 3. Nxe5 d6 4. Nf3 Nxe4 5. Nc3 Bf5 6. Qe2 1-0
Black is going to lose a piece, so he decided to resign. What had gone wrong? Well, the game that had slipped into the Informant had in fact been a pre-arranged draw between GMs Tony Miles and Larry Christiansen, in which they each mindlessly played out some moves and shook hands:
[White "Anthony Miles"]
[Black "Larry Christiansen"]
1.e4 e5 2.Nf3 Nf6 3.Nxe5 d6 4.Nf3 Nxe4 5.Nc3 Bf5 6.Nxe4 Bxe4 7.d3 Bg6
8.Bg5 Be7 9.Bxe7 Qxe7+ 10.Be2 Nc6 11.O-O O-O 12.Re1 Rae8 13.Qd2 Ne5
14.d4 Nxf3+ 15.Bxf3 Qd7 16.c3 b6 17.Rxe8 Rxe8 18.Re1 Rxe1+ 19.Qxe1 Kf8
If our strong GM had spent even a few moments thinking about the why of the "script" he'd just glanced at, he never would have played as bad a move as
5. ... Bf5??. Note too how important it was for White to be ready to improvise; Black's fifth move is so bad that White couldn't have expected it to be played, but when it was, White rightly sensed that something was off about it, and duly found the appropriate punishment. The moral of the story: even the strongest of players need to be careful not to rely too much on book "knowledge." It all ended well for our hero though, as he now enjoys the title of world champion.
Zapata - Anand (Biel 1988)