Judaism 101 says (and I have heard it many times):
Judaism acknowledges that many people who ask for charity have no genuine need. In fact, the Talmud suggests that this is a good thing: if all people who asked for charity were in genuine need, we would be subject to punishment (from G-d) for refusing anyone who asked. The existence of frauds diminishes our liability for failing to give to all who ask, because we have some legitimate basis for doubting the beggar's sincerity.
What is the source in the Talmud for this statement?