The moves Bg5 and Bb5 usually have one the following six purposes:
- To pin a knight on f6/c6
- To provoke ...h6 or ...a6, weakening the pawns
- To trade White's bishop for its counterpart (usually because the position later will make Black's bishop a better piece than White's)
- To take the knight in order to break up the pawns behind it
- To take the knight because it defends a central square White wants to occupy with a piece, usually his own knight
- To set up the removal of the knight and prepare a mate at h7 once the knight defender is eliminated
If Black responds with ...h6 (say), White can maintain the pin with Bh4. On the kingside, Black is left with a difficult choice: kick the bishop away with ...g5, weakening the kingside, or leave it there as a loose piece.
White often intends to transfer the bishop to the diagonal h2-b8 anyway, when Black's punting the bishop only wastes a tempo and weakens his kingside.
The same is true about the possible destinations of the bishop on the queenside. On the a2-g8 diagonal, it hits the f7 square, which is usually uncomfortable for Black in the KP openings (and obviously good for White).
In some openings, White wants to exchange the bishop, with or without the knight already on f6/c6. In the Sicilian Defense, Rossolimo Attack, White plays 3.Bg5 in reply to 2...Nc6, but Black hasn't moved the d-pawn, so there's no pin. Black doesn't normally play ...a6, because he's not feeling any pain from the Bishop (yet).
In the Canal-Sokolsky Nimzovitch Variation of the Sicilian (also known as the Moscow, although there is a completely different Prins Moscow Variation), the line runs like this:
[FEN ""]
[Event "B51"]
[White "Sicilian Defence"]
[Black "Canal-Sokolsky Nimzovich"]
[Result "*"]
[ECO "B51"]
1. e4 c5 2. Nf3 d6 3. Bb5+ {What?? No knight to pin?} Bd7 4. Bxd7+ Qxd7 5. O-O (5. c4) *
...there's no knight there; White just wants to get rid of Black's good bishop, and saddle Black with a bad one unless he either fianchettoes it on the kingside, or moves all of those pawns (ain't gonna happen). So he invites it to interpose, and trades it off.
In the French Defense, the Alekhine-Chatard attack (strictly speaking, the Albin-Alekhine-Chatard), White leaves the bishop on g5 and props it up with his own h-pawn, daring Black to take it. If Black does, he ends up staring down the barrel of White's king's rook on an open file:
[FEN ""]
[Event "C13"]
[White "French Defence"]
[Black "Albin-Alekhine-Chatard Attack"]
[ECO "C13"]
1. e4 e6 2. d4 d5 3. Nc3 Nf6 4. Bg5 Be7 5. e5 Nfd7 6. h4 *
Black doesn't play ...h6 here, since there's no point; White will just take on the bishop e7.
In the Ruy Lopez, in 75% of games Black plays 3...a6 immediately. He has no concerns about weakening his queenside; in fact, the pawn storm it initiates often constitutes his main counterplay.
So, these are some illustrations of what the bishop is doing there, and when it may not make sense to chase it.
Note: Many of these ideas are also present in variations with colors reversed, i.e. ...Bg4 and ...Bb4. The latter is the primary theme of the Nimzo-Indian and Bogo-Indian Defenses.