> 1. It formed **inside him** an ambition to teach his students all the more. 

> 2. It formed an ambition to teach his students all the more **inside him**. 

> 3. He kept **in the book bag** an apple. (awkward or marked)
 
> 4. He kept an apple **in the book bag**. 

The differing acceptability of these examples is due to a phenomenon known as *HEAVY NOUN PHRASE SHIFT*. It gives us the illusion that we are able to move the preposition phrases in the sentence around, but really what we are moving is not the preposition phrases; it's the noun phrase *ambition to teach his students all the more* on the one hand and *an apple* on the other.

We term a noun phrase as *heavy* when it is long. You'll notice that the noun phrase *ambition to teach his students all the more* is very heavy. The noun phrase *an apple* is, of course rather light. When a noun phrase is the Direct Object in a sentence, it normally occurs directly after the verb (or if there is an Indirect Object, after the Indirect Object). If there are other phrases, for example locative or temporal Adjuncts or Complements we cannot just switch their positions willy-nilly, or the sentence will be deemed ungrammatical:

 - *I met in the office canteen just now Bob.

In the sentence above I put the Direct object *Bob* after the Adjunct (or "adverbial") *in the office canteen*. Because *Bob* doesn't directly follow the verb, the sentence would be regarded as ungrammatical. However! If we make the  Direct Object very *heavy*, in other words if we make it *long* we can move the Direct Object to the end of the sentence, no problem:

 - I met in the office canteen just now that guy Bob who you bumped into the other day.

Now that the Direct Object is a ten word noun phrase, *that guy Bob who you bumped into the other day*, we can move it right over all the other phrases to the end of the sentence. It is perfectly grammatical.

In the Original Poster's examples (1) is fine because the noun phrase *an ambition to teach his students all the more* is heavy enough to move to the end of the sentence past the preposition phrase *inside him*. But in the Original Poster's third example, *an apple* is too short to justify moving to the end of the sentence. It needs come after the verb and before the preposition phrase *in the book bag* to sound natural. But this has nothing to do with the preposition phrase, it's just because the noun phrase, the Direct Object, is very light. The feeling that we're moving the preposition phrase is a kind of illusion.