This is a difficult question. "To" is generally used to show who or what is going to receive something or be moved toward; think of the word "toward." "For" is used similarly, but is more for the intent of movement. Here are some examples of the use of each:
"I made a birdhouse for my uncle. I gave it to him." In this sentence, "for" is used to show who benefits for the action and "to" is used to show direction on the verb "gave."
"I wrote a letter to my manager, it was for my resignation." In this sentence "for" is used to show why something is happening and "to" is used to show who the letter is intended for.
"I made a cake for you, let me give it to you." In this example "for" shows the intent and "to" supports the action of the cake being given.