Guitar scales are the road maps of the fretboard, allowing the player to understand which notes to hit as they embark upon a solo. Even guitarists who do not wish to study music formally should learn the basic major, minor and pentatonic ("five note") scales, to get a feel for the most common patterns and links between notes. Another option is to learn the "blues" scale, which is at the heart of much modern pop and rock music. Once you know which key a piece of music is in, these basic scales will provide you with an instant way to enjoy playing along while making sure you can stay in tune.
The key of a piece of music is the scale upon which it is based. So, a song in the key of G major draws its fundamental notes from the scale G, A, B, C, D, E and F#. The root note ("tonic") of this key is G itself. A song in G will typically (although not necessarily) gravitate toward the tonic note, which is the natural resolution of such a song. An example is The Velvet Underground's "There She Goes Again," which commences with a rattling introduction of A, C and D before dropping back ("resolving") to G. Listening to music, you might find that you are waiting to hear a specific note, which feels like it must inevitably be sounded. If that is the case, you are listening to a "tonal" piece.
The standard guitar tuning is EADGBE, an all-purpose tuning that allows the most common chords to be sounded relatively easily, especially by "barring" the A or E shape at different frets to change the pitch. However, folk guitarist Davy Graham popularized the notion of retuning the guitar to more "open" tunings, such as DADGAD. Metal and heavy rock guitarists, meanwhile, often detune their guitar to "drop D", which gives a darker, deeper sound. Guitarists shouldn't limit themselves to standard tuning, as there are many different tunings to explore. But be careful not to try to tune a string up too high, as you might snap it.
Many guitarists have done their best to wring new sounds out of the instrument. A good example is Sonic Youth, whose guitarists Lee Ranaldo and Thurston Moore have tried techniques such as "sawing" the strings with a violin bow, as well as using a plethora of effect pedals and alternate tunings. A problem with learning guitar theory is that it can lead a player to feel "boxed in" by too many rules. According to Sonic Youth drummer Steve Shelley, many bands "rehash things that have been done a million times before." Just because you have learned a particular scale, or are aware that a particular note will definitely work, try not to fall into the trap of automatically using it without thinking.