Generally, they ping your account to make sure that the card is valid and the address matches what you gave them. Think of it as a pre-authorization at a hotel, or when you buy gas. When you look at your online bank statement after visiting a gas station, it generally shows a $1 pre-authorization ping, which is replaced by the actual amount of your purchase when it's processed later.
In the case of Yahoo, I would guess they're going to ping your card to validate the address. If it's being declined, that probably means that either a) your card is maxed out, overlimit, not valid for purchases or expired, so that even the $1 charge won't go through; or b) you have entered an address on Yahoo that doesn't correctly match the billing address of the credit card. This could be because you made a typo, moved and didn't change the address on the card, or you used a street address on Yahoo and the credit card bill comes to your PO box.
The short answer to your question about why they need that kind of verification is that there are too many people out there using the internet to do evil things, and Yahoo can be held responsible if they don't take measures to track who is using their services. Yahoo offers many valuable services to the internet community at no charge, so the time it takes to provide valid credit card information to confirm your identity seems like a small thing to ask.