What is the purpose of 3...a6 in the Ruy Lopez? It doesn't kick the bishop off that diagonal, and playing ...b5 later puts the bishop on another great diagonal and is supposedly bad for black (an explanation of this would be great too). So why is 3...a6 in the main line for black?

[FEN ""]
1.e4 e5 2.Nf3 Nc6 3.Bb5 a6
Playing ...b5 later is not bad for black. Playing it immediately isn't so great, but Black almost always plays ...b5 at some point (unless White plays Bxc6 first!).

The main reason to play ...a6 early is that you can now play ...b5 any time you want to if you decide that you don't White to take the knight on c6. If you don't play ...a6, and then later decide that you want to kick the bishop away and start by playing ...a6, White can go ahead and play Bxc6. If you've already played ...a6, you can go straight to ...b5 and White doesn't get a chance to capture your knight in response.