TO and FOR
The difference between the two can be explained as follows:
1. "To" usually implies direction like: form Dan to Tim. In this sense "to" can also be replaced by "till/until" from 7 to or till 8. This is the reason why "to" is part of the infinitive. "For" implies purpose that's why it can also mean "because":
I apologize for being late: because I was late
"I did it for you" is friendly when compared with "I did it to you"
I wrote to you (from me to you) whereas I wrote it for you” explains the reason or purpose

2. In collocations or phrasal verbs this difference cannot be seen so easily.
3. Sometimes the two are interchangeable without any important difference. "To" is often more idiomatic and formal than "for".