I tried Googling but it seems there is no answer for this one. So the internet assumes everyone knows what scales are for? Why should I learn them? Are they important to be a good guitarist?
Scales are important for a guitarist, just as learning good grammar is important to speaking properly.
If you are intent on "playing" guitar then learning the language of music is going to be inevitable.
From my own personal and teaching standpoint, guitar music should start with Chords. As opposed to notes. To me they are the most practical form of music as they are immediate. Consider chords to be words.
So like a child, you are taught "MUM", "DAD", "YES", "NO" - so you might learn the chords G, C and D. That may suffice you if all the conversations you will ever want to do on guitar is in the Key of G, eg. But soon you will want to know other things, like Em, Am and now the intensity and complexity of MORE KNOWLEDGE comes into play.
Well that's where SCALES comes in. They are the alphabet of the chords that you play. It can make a difference from a chord progression / accompaniement sounding like "GOOD MORNING" to "GOOD MORNING, HOW ARE YOU? I FEEL FINE!, ISN'T IT A GREAT DAY TODAY?"
Scales can set the tone. Knowledge of this alphabet allows you to add twiddles and trinkets to your rhythm work... that is, adding little fills based on your knowledge of scale shapes or forms or even better - true music theory where you know whether a particular note is a flat 3rd or diminished 5th and whether it is a Lydian or a Phrygian mode of a scale. All this KNOWLEDGE of SCALES allows you to set the mood and tone of your playing.
Now the connotation of scales is another thing entirely. In my mind, metal and hard rock styles have tinged the learning of scales slightly as SCALES often gets equated to SHRED. But that's not the case. Even styles like Blues and Jazz and Latin all have their tones and styles completely defined by the SCALES that are dominant in their music structure.
Last week, for example, I was explaining to one of my students the elusive difference of the MAJOR and MINOR scale change of a Blues progression. This was invaluable information to him - because it now explains what he can hear in records/songs. He knew there was something going on but he didn't have the vocabulary to explain it - which translates into better technique and conscious choice in what notes to play.
SCALES will lead to understanding; the ability to know and recall relationships between notes; this leads towards understanding the relationship between chords and how this sets an emotional mood; this leads towards understanding good composition and song writing; this leads towards good technique and more interesting rhythm work; this leads towards a roadmap for soloing and knowing various melodies to play over the right chords at the right time; this leads to complete mastery of the guitar.
LEARNING SCALES can do this for you. It's invaluable and will open up the guitar for you.
Scales are the foundation to building the chords. Each scale, whether it be major, minor, dominant, Lydian Dominant, Harmonic minor, pentatonic and on, enables you to construct different set of chords, because of its structure, i.e., the intervals between notes of the scales.
In this case scales are then the backbone of chord building and harmony.
And, reversed, when you see the chord and you know from which scale it has been constructed, you can use this scale to improvise or compose a melody over that chord.
So if you see a G7 chord, it's a C major scale chord, or G mixolydian if we were talking about modes. So you can more or less play notes of the C major scale and they will sound good over this chord, but not all of them equally good.
So, you can use scales with melody and improvisation.
Considering both statements above, scale knowledge facilitates composition a lot. It tells you which note will be diatonic, i.e., a scale notes, and which one will not be, which can be used to build tension for example.
Scales can be thought as one of the systems to organize and get to know well your fretboard.
Many rock, blues, metal players rely on this system solely.
If you are curious, there is the "CAGED" system, based around chord shapes popular amongst jazz players, but there other systems as well.
I'm not a theorist, nor do I have a proper musical background, but from my experience, scales are the basis for the composition.
In other words:
The scale is the structure and everything moves around it. For example, a guitar solo can follow one or more scales, and for the layman/listener it may seem random notes being played, but in fact those notes follow a structure.
If you would like to be very picky, this structures can be found everywhere, so in my opinion, a scale is a structure that you follow. In an extreme, a very complex solo, that seems it not following any scale, can be following a mix of scales or even variations of scales, but this can be refuted by some, saying that a random play is just that: random... I don't agree, I'm one of those maniacs that think of a structure behind everything :)
Knowing this, if you learn scales, it will help you improve your playing (may it be composing or improvising). Many people try to step out of the normal scales and make variations, that's the beauty of it, because then they sound different but still come from a familiar origin. Mixing scales is also very useful and can give a nice twist to your solo.
Solos aren't the only thing based on scales, a rithm/chord also has the basis on a scale. Knowing scales also helps you with the chords.
I'm probably not very accurate/may not have used the correct terms, but I think this answer will at least contribute with the view of a self-learnt player (someone more theoretical will give you a better answer).
I'd also add that practicing scales allows you to concentrate on learning the physical motions of going from note to note (this is why interval practice is useful as well). As with any other physical action, more practice allows you to spend less cognitive resource on "let's see, C to D is that, and D to G is that, and...", allowing you to think, "oh, C-D-G, right", with the notes occurring as fast as you can think them - and as you practice further, without even the subvocalizations of note names: the note becomes the action without your thinking about taking the action at all.
This will greatly enhance your ability to sight-read and improvise, and to concentrate on other aspects of your performance - e.g., tone, dynamics, and expression - because you will have the cognitive resources to do so.
Two points to complement the other answers:
Let's take one scale, C major, C, D, E, F, G, A, B, chosen so we don't have to deal with majors and minors and naturals and all that confusion. You may know that as "do rey me fa so la ti do".
Let's take every other note, C, E, G. Those are the root, third, and fifth, the building blocks of chords. Skip forward a few to F. F, A, C. One more, to G. G, B, D. Those are the root, fourth and fifth chords. I, IV, V are the three major chords, which are all you need for a whole lot of songs. The same processes will get you D minor, E minor and A minor. Plus B diminished, which is beyond what I want to handle today.
A rule of harmony is that, for every note in a melody, you play a chord that contains that note. (Not everything does this, but it's a way to work it.) So, "Twinkle Twinkle Little Star" is C C G G A A G | F F E E D D C. First, once you have a sense of the scale, you can identify it as part of the C major scale. (Actually, I think I could have hit this part first, but ahh well.) So, chordally, you might play the chords C C G G F F G over those notes, or C C C C F F C. C C G G Am Am G. C C Em Em Am Am G. All sorts of fun choices.
So, knowing scales help you know how to take apart a song and know what you can play behind it.
Scales are trying to use some "math" to describe sounding of music intervals. Anyway there are people who say that they are necessary for music composition and someone else call it unnecessary limitation. There are realations between keys, scales and chords that will allow musician to improvise easier. Also music score bases on scales so if you want to learn reading it you need to learn at least Cmajor.
When I was a kid I learned to play piano first, then a bit of trumpet, then picked up guitar in my teens. Piano taught me to read scales, and I learned a bit about how melody and chords work. Guitar is my favorite, and I played it in jazz, country and rock bands for years.
I decided to take some music theory classes at the local community college, which, with what I'd learned from my jazz and piano, really opened up my understanding of what makes music work, and allowed me to be a lot more expressive.
Instead of guessing what notes would work, or learning riffs without understanding why they sounded good, I knew what a riff did, how to transpose it, enhance it, modify it to fit with a different scale, etc.
In other words, my understanding of what makes all music tick suddenly grew, and it's made me a lot better musician, and gave me a lot better appreciation of more forms of music.
Knowing scales and how they fit with chords gave me the tools to try to sound like me, not like someone else, and what I play is mine, not someone else's riffs regurgitated. I like that a lot.
You are playing a guitar. All the notes on your guitar (piano etc) are in a scale - the chromatic scale. From my outside perspective if you play some notes together it is a chord, and if you play tunes on a restricted set of notes (ie not playing all the notes) that would be a scale. If you use the same set of notes again you will save time by giving the scale a name to help remember it. If you play with other people, as they all call those scales the same thing it might help to learn their names for scales. I worked out the maths of music in the 1980s and I would argue that there are 57 main Keys based on 7 scales (I'm sure many people here would argue about that) but you would want to learn one scale at a time. Once you can play a scale pattern you can slide the same pattern along the neck by one fret (or more) to play in a new key (still the same scale though - keys are named after the note they 'start' with, scales can start anywhere). Good luck with your music.