When a guitar has good intonation all the notes on the fret board sound in tune with each other. Then chords played up the neck will play in harmony with the open strings. For good intonation you need: properly aligned saddles, an accurately filed nut, and frets with crowns in the middle. (For the best intonation you need a compensated nut as well.)
Steel strings guitars need compensated saddles in order to play in tune. Each strings has a small stiff portion at the contact point at each end. These dead ends don't move when the string is plucked. The treble E string has about 1/32" dead ends so it's saddle needs to be moved back 1/16". The bass E string saddle is back about 3/16" to 1/4". The other strings fall in between. Steel string acoustics have these measurements built in, so the saddle is installed at an angle.
Electric guitars have movable saddles so each string's length can be adjusted. Usually the G string on an electric guitar is unwound, and is actually stiffer than the thicker wound D string. It's saddle is placed slightly back of the D string. Here's a PRS saddle showing the Z shaped compensation pattern:
The string slots in the nut need to be filed with a slope, front to back, so the strings break off the very front of the nut. Sometimes a slot gets worn and the break point moves farther back, away from the first fret. This creates tuning problems everywhere on that string. This problem is pretty common. Usually filing the slot is all that's needed to fix it.
This brand new left handed Stratocaster had serious tuning issues. All the strings were breaking off the back of the nut. You just couldn't tune the thing. Someone at the factory had probably taken a right handed nut and just flipped it around, without correcting the slopes. Then they intonated the guitar by matching the open note to the octave at the 12th fret and all the saddles ended up 1/8" too far back ... wrong at both ends.
The string slots also need to be cut to the correct depth. High action at the nut means you basically have to bend a note to reach the first fret, so the cowboy chords are all sour. One customer had a new Rickenbacker 12 string that wouldn't play in tune without a capo. Everything else about the set up was great, but the strings sat about .045 inch above the first fret. I lowered them to around .020" and the problem was solved.
I like to file the slots at an angle about half way between the plane of the frets and the plane of the peg head. This assures good even contact across the nut and a clean take off point at the front edge.
Ideally the frets should be crowned, so the strings contact them in the center. If they're worn flat the contact points will be at the front of the flat area. It's like moving the frets away from the nut, throwing off the scale of the neck.
Even a new set of strings can have one that's defective. A customer with a Taylor acoustic said the intonation on the A string had "gone off". The saddle was fine, no chips or damage. The problem had started when she put on new strings, so I installed a different brand and ... problem solved.
I'm a big fan of the Earvana compensated nut. (I install them in all my personal and custom guitars.) Ideally the nut should be compensated as well as the saddles. On steel string guitars the nut is placed so the high E string plays a true F when fretted at the first fret. But all the other strings play sharp at the first fret, the G being the worst. Moving the nut 1/16" closer to the first fret would with help the E,A,D, and G strings, but then the B and high E strings would play flat. So a straight nut just won't play in tune on the lower frets.
The Earvana nut has little shelves that move the contact points forward just the right amount. Each string is individually compensated so the notes at the first fret are true F, A#,D#,G#, C, and F. The change is very refreshing.