Many of the traditional answers have already been mentioned. Glen Stassen provides a novel one here that I've found more compelling than most.
TL;DR: He suggests that it means, "Do not give your trust and loyalty to [gentile powers, especially Rome] instead of to God." (p. 290)
He gets to this through an argument that there is a triadic structure running through the entire body section of the sermon on the mount consisting of:
- traditional teaching (eg. "you have heard it said, 'you shall not murder'")
- a vicious cycle ending in judgment (eg. anger and insults lead to judgment)
- a transformative initiative that escapes the vicious cycle. (eg. "be reconciled to your brother . . . reach agreement quickly with your accuser on the way to court")
- (optionally) an explanation of (3) (eg. "or he may hand you over to the warden . . . ")
The case he makes for the first 13 of these is beyond the scope of this answer, but here's how he argues the triad applies to this section:
- Traditional Teaching: "Do not give what is holy to dogs, or throw pearls before pigs"
- Vicious Cycle: "They will trample them underfoot and turn around and tear you to pieces"
- Transformative Initiative: "Ask and it will be given to you, seek and you will find, knock and the door will be opened
- Explanation of (3): "For everyone who asks receives . . . how much more will your Father in heaven give good gifts to those who ask him!"
Parallels in both Rabbinic and New Testament literature suggest that dogs and pigs are frequently used as epithets for gentiles, especially for Rome.
If Stassen's interpretation of these sections as bearing a triadic structure is correct, we should be able to infer the meaning of 7:6 from the contrast with 7:7-12. 7-12 are all about reliance on God's provision, which would suggest that the 7:6 teaching is about not trusting the Roman and other gentile powers. In Stassen's words:
What then, logically, can the traditional teaching mean? Do not give your trust and loyalty to the dogs and pigs instead of to God. The clear meaning of the transforming initiative tells us what the theme of the unit is: trust and loyalty to God rather than to the "dogs and pigs"--just as 6:19-34 taught us to give our trust and loyalty to God rather than to treasures and mammon, and just as 6:1-18 taught us to give our trust and loyalty to God rather than to prestige before others. (290-291)
This also reshapes our interpretation of the following verses somewhat, as Stassen notes:
The assumption that the unit begins with v. 7, so that the teaching about prayer comes without a context, leads many commentators to conclude that "ask, and it will be given to you" and "everyone who asks receives" means that all prayers will be answered with good things, which then seems a pious illusion. Jesus prayed in Gethsemane that this cup pass from him, and he did not receive an affirmative answer. In the context of the full triad, however beginning with v. 6, it means God is faithful as the Roman power structure is not. They will trample you under foot and tear you to pieces (as they did in 70 C.E.) but God gives good gifts. It is not a general, context-free abstraction claiming that God gives whatever anyone asks in prayer but a context-specific claim that God answers prayer by contrast with members of the Roman power structure which, if we put our faith in them and let them shape our ethics, will turn on us and tear us to pieces. Then 7:12 is part of the same theme, as its beginning "therefore" suggests: as God gives good gifts to those who ask, therefore you should give good gifts of love to others, rather than following the ethics of giving gifts to those who might advance your prestige and wealth as those who put their trust in the Roman power structure do. (p. 294)
So far, this is the only interpretation that I've found that makes any kind of contextual sense of this statement as a part of such a carefully-crafted whole as the Sermon on the Mount.