Short-selling and securities lending
For retail investors, the most common place that securities lending comes into play is with short-selling. In short-selling, the name of the game is to sell an asset for a bunch of money, then quickly buy it back for a lot less, pocketing the difference. It can be difficult to find enough shares that are for sale to do this with, and sometimes it's just a big headache to collect them, so short-sellers often borrow securities instead of buying them.
When they borrow these securities, like your shares of XYZ, Inc., they're responsible for paying you for the privilege. You may get a little interest or some other kind of consideration, but there is a real risk that your securities will not come back to you, which is why it's still a risky investment move. If you're working with a reputable brokerage, however, your value should be returned even if the actual asset isn't, since they generally require a large amount of collateral to be put down by the short-sellers who will be borrowing your stocks.
Benefits to securities lending for the lender
But what happens if your stocks don't come back to you and you miss out on the joy of compounding value? That's a risk, but the benefits are significant.
Since reputable brokerages require a lot of collateral -- sometimes much more than what the securities are worth at the time of lending -- you should at least get your money back, plus interest and other fees, depending on the type of asset being loaned. This is one way to get some cash out of your investments without actually selling them.
Just like renting out your house during the week you'll be on vacation elsewhere, securities lending allows you to get a little profit from something you weren't really using actively anyway. These "securities rentals" are short-term and come with contracts that spell out the many possible scenarios that could happen and how the borrower will be expected to behave in said situations in order to minimize your risk.