The "to" is always required to form a "to" infinitive, and so "to" cannot be omitted here. However, there are other structures that have the same form as the bare infinitive. One of these is the imperative.
It is possible that you could use a quoted instead of an infinitive phrase, and the quote could be an imperative sentence (as could be used to give ...
No, it’s not always necessary. Here’s why: first of all, your example should be one sentence, not two—there should be a comma between 'himself' and 'but'.
Now the sentence reads:
“He wanted to go to the park by himself, but I didn’t allow him to.”
If you’ll notice, the second part of the sentence is not a complete thought—“I didn’t allow him to” ...
You have tagged the question "poetry". In poetry, anything goes.
In prose writing, what you're describing is known as a split infinitive.
To split an infinitive is to put another word, or phrase, between "to" and the infinitive verb.
Here are examples of split infinitives:
To boldly go where no one has gone before.
--- Star Trek
Splitting the ...
 What's the trick to [getting this chair to fold up]?
 some tricks [to speed up your beauty routine].
If clause is of the -ing type, then the preceding "to" is a preposition, and if the clause is an infinitival then "to" is a subordinator serving as a marker within the clause.
Thus "to" is a preposition in  and a subordinator in 
Some nouns + get mean achieve or obtain can be used like this:
The trick to getting this chair to fold is [x]
The solution to getting these voters to turn out is [x]
The answer to getting more people at the park is [x]
get x to means: to obtain or achieve or persuade
Getting people to understand you can be difficult.
Getting better quality/price ratios is ...
I've edited the title question (which appeared far too general and had been in part addressed on ELU before). There are a couple of particular usages involved in these specific examples.
'Is a trick to', like (the probably less informal) 'is a means to', can be followed by a present participial clause:
This imperative is derived from a causal 'law' ... ...
This example simply isn't what you would call perfect English. Perfectly understandable, but the author was probably more worried about the technical meaning than of the grammar. Any of the following would be considered 'more correct':
If the number differs, the PCI bus orders that the packet be re-sent.
If the number differs, the PCI bus orders the packet ...
"Looking forward to(something)" is a phrasal verb, meaning that you treat the phrase as you would a verb. Therefore, the something in question can only be either a
So, to eat+ing is the correct answer.
“Looking forward to eating” is correct here.
“Looking forward to” is acting like a phrasal verb that wants a direct object — a noun.
I am looking forward to the test
She is looking forward to the new “Star Wars” movie.
They are looking forward to a better future.
We are looking forward to running a marathon.
I was looking ...
2 is incorrect English. "Happened" is already in the past, so "was" is unnecessary. You can say, "He canceled that order minutes before it happened."
1 is technically correct, but both of these examples suffer from another problem: An order doesn't "happen." An order is placed, and then it is fulfilled. To cancel an order, it must have been placed. So what ...