If you then, who are wicked, know how to give good gifts to your children, how much more will your heavenly Father give good things to those who ask him. "Do to others whatever you would have them do to you. This is the law and the prophets. (Mt 7,11-12)
Jesus is introducing the Father who gives, and gives good gifts only. And He gives to those who ask him.
The same Jesus tells us that the Father knows what one needs and He gives even without asking for it. (Mt 6, 25ff.) But seek first the kingdom of God. Here, Jesus tells his followers to seek the kingdom and not to worry about the wants and needs. Kingdom should take precedence.
Jesus speaks of the Father who gives to his children whatever they ask. So treat God as a Father. Tell him how things are with you. Ask, search and knock and he will not let you down. This is prayer and this is the underlying message of the Sermon on the Mount.
Relationship with God should be that of a Father and a child. And this is expressed in asking for good things and they are granted by the Father.
Next verse speaks about the relationship between one another. Do to one another what one wants done to him. This again, would be doing good to one another.
We are all children of a Father who is good and gives good things and so we as children of the same Father do good things to one another.