This is a variation that was played fairly frequently, but it has been more or less worked out to a draw, so it is less common at the top levels now.
The Ruy Lopez is a very concrete opening, and the capture on c6 has to be carefully considered as it relates to the exact position.
In terms of opening principles, you're giving up a bishop for a knight in an open position. If you could take the pawn on e5, it might be good, but the pawn is protected via the tactical shot 5.Nxe5? Qd4! when white has basically given up the two bishops for very little compensation in a wide open position.
Another downside to Bxc6 is that the black's light square bishop is developed by dxc6, allowing it to come to g4 without waste of time. Indeed, one of the most critical lines continues 5. O-O Bg4 6. h3 h5 when black is offering a piece for attacking chances along the h file.
With all of that said, this is a very common motif in the Ruy Lopez (Bxc6). The pawn structure after d4 and exd4 is very good for white. If all of the pieces were traded off, white would win the king and pawn endgame by making a passed pawn on the kingside and black cannot make a passed pawn on the queenside.
There are also many cases when spoiling your opponent's pawn structure is very good. For example, if black has castled kingside, and a bishop can take on f6 and force ...gxf6, this is almost always good for white. The king becomes very exposed with the g file open. In the Spanish Four Knights, one player or the other will very frequently take on c6 or c3.