So let's start with the Ruy Lopez, as featured in the game Garrett-Dooley. One of the most popular openings there is, it starts 1.e4 e5 2.Nf3 Nc6 3.Bb5, taking us to the position above here.
Now why, you may ask, is the bishop developed to b5, rather than the more "classical" square c4, where it attacks f7 and inhibits black's ...d5 break? Well, the answer is quite simple: the bishop is there to threaten Bxc6 followed by Nxe5.
Except, of course, that it's not that simple. If black replies 3...a6, white can't win a pawn immediately with 4.Bxc6 dxc6 5.Nxe5 because of 5...Qd4, and the fork of the e5 knight and e4 pawn wins black the pawn back with probably the better game. No, the force of the Bb5 idea is something slightly more subtle: it creates a potential threat, rather than an immediate one.
Now look at the subtle difference between this and the last diagram: white has played d3, protecting her e-pawn. This means that when black played the careless 6...0-0?, white could (and should) have won a pawn with 7.Bxc6 dxc6 8.Nxe5, exploiting the opening's thematic idea. Had black been alert to this, he would have prevented it with 6...b5 or 6...d6.
Which leads us on to the real reason why white plays Bb5 in the Ruy Lopez: it is to encourage black to play ...a6 and ...b5 early on. The bishop ends up on the same diagonal as it would have done had it gone straight to c4, but black has weakened his queenside to get it there. A number of lines in this opening then go on to attempt to exploit this weakening with a4, with the aim of either giving black a weak pawn on b5 or (if he advances it to b4) establishing a nice square on c4 for the knight.
Are these lines particularly good for white or black? It's hard to say; theory in critical openings like the Ruy Lopez changes all the time. But one thing is easy to say: if you are going to play this opening, don't forget the reason the bishop went to b5 in the first place.