EDIT After searching the site (why didn't I do this before writing?)
I found this answer to a similar question All you have to do is read” vs. “All you have to do is to read” Which explains far better than I could ever do.
Here are a few online references which deal with the aspect of choosing between the bare infinitive (or base verb) and the full infinitive form (with to).
My English pages
The bare infinitive
The bare infinitive is used as the main verb after the dummy auxiliary verb do, or most modal auxiliary verbs (such as will, can, or should..)
I do know him
I do like you.
I can do it .
Uses of the infinitive
As complements of other verbs. The bare infinitive is used as
complement of the dummy auxiliary do, most modal auxiliary verbs,
verbs of perception such as see, watch and hear (after a direct
object), and the verbs of permission or causation make, bid, let, and
have (also after a direct object). The to-infinitive is used after
many intransitive verbs such as want, aim, like, fail, etc., and as a
second complement after a direct object in the case of verbs such as
want, convince, aim, etc.
As a noun phrase, expressing its action or state in an abstract,
general way, used as the subject of a clause or as a predicative
expression: "To err is human"; "To know me is to love me". The bare
infinitive can be used in such sentences as "What you should do is
make a list." A common construction with the to-infinitive involves a
dummy pronoun subject (it), with the infinitive phrase placed after
the predicate: "It was nice to meet you."
"Do/does/did bare + infinitive" and "Infinitive [after modals]"(http://www.grammaring.com/the-infinitive-after-modals)
Modal verbs (can, could, may, might, will, shall, would, should and
must) are followed by a bare infinitive:
I could hear the dog barking outside.
You must be joking.
He may have caught the train.
You should have told me earlier.
In the case of:
- All I must do is to prepare myself for the test.
- What we should do is to teach children how to think.
The to-infinitive is used after ought, used, be and have which are called semi-modal verbs or modal auxiliary verbs. They are different from other modal verbs in that they are followed by the to-infinitive.
She ought to go home now.
You ought to see a dentist
He used to go down the pub a lot.
She never used to drink wine at lunchtime
We have to wear a uniform for work (meaning of "external" obligation)
I'm sorry, I have to leave now. (or "... I must leave now")
be + infinitive see the Wikipedia link
(often used to talk about a future arrangement or plan and for giving orders)
The President is to visit Great Britain in the Autumn.
John is to leave tonight
They are to marry next week.
You are to do your homework
Tell her she's not to be back later than midnight.
EDIT #2 / Conclusion
Both the bare infinitive and the to-infinitive forms are acceptable, with the first structure sounding more natural and clearly used more frequently in everyday speech. I was intrigued by the question and wanted to know why the to-infinite structure could be used. I believe in the sentence
All I must do is to prepare myself for the test
The is + to prepare expresses an arrangement or plan sometime in the future. This is grammatical, albeit very formal. It nevertheless sounds better than the equivalent:
All I have to do is to prepare myself for the test
The repetition of the particle, to, in have to and to prepare sounds awkward to my ears, but interestingly the meaning remains virtually unchanged. Have to and must both express a form of obligation, although grammar books will tend to emphasize that have to is more commonly preferred when speaking about the law, rules, and regulations; whereas must expresses personal choice (I must see that film) or necessity.