1. The governments could identify the income of people. Indeed, the governments can easily reach to that kind of data. According to this data, they can make distinction among them while providing the help.
2. While helping the people in need, the governments can put some limits to that need. It helps those people not to become lazy and fully dependent of the governments. Indeed, when there is an availability of certain jobs, the latter must become priority over governmental aid.
3. In many developed governments, there are social workers who observe and control the situation. Social workers make it easy for the people in need to get the aid they need and they help to reduce falsification and corruption in the process.
When there is no help and hope for the poor communities, they turn into illegal activities, such as gambling and informal trading which stated in the question. Those activities are not illegal in reality, however among poor communities it can make its way into illegal waters when governments cannot control the situation. This is the case of underground casinos and black market.