Why is stranding obligatory in the sentence, "It depends on who I give it to" whereas it is not in "I wonder to whom I give it"?
Hello, Deng—Your question presupposes that stranding is obligatory in the first example but not in the second. Why have you presupposed this?
In my view, Pied Piping (preposition fronting within the embedded interrogative clause) is not ungrammatical in either case.
However, it would be awkward and unusual to say "It depends on to whom I give it." Notice that "who" must change to "whom" with Pied Piping.
Thus, I disagree with your implicit belief that stranding is obligatory in the first sentence. But I would find it awkward.
As to why, here is a quote from the late Frederick Wood, a grammarian whose explanations were celebrated in another recent thread.
Quote: ". . . even where a preposition has front-position in a direct qustion it is usually given end-position in an indirect one: thus To whom did you give the message? but He asked me who(m) I gave the message to. The reason probably is that to place a prepositional adjunct like to whom immediately after a verb or a pronoun to which it does not belong would make an awkward or even a misleading syntactic construction. Until we got further into the sentence and found that such an interpretation was impossible it might appear at first sight to be adjectival (me to whom, &c.)" (p. 91).
- Frederick T. Wood, "The Place of the Preposition with Interrogative Pronouns and Adjectives," ELT Journal, Volume XII, Issue 3, April 1958