Hi Jonas. It is really case, by case, but one difference is that you "do something for someone", while you "give or deliver something to someone". I think for is used more when something is being created for someone or something, while to is more about something being derived or traveling to somewhere.
I hope this was helpful. If you would like more examples and a more in-depth explanation, sign up for my tutoring lessons.
Jacobo The Teacher
"We went from the restaurant to the party."
"Talk to your teacher and get more information about the exam."
"I go to the office every morning at 9am."
"He sold his car to me for $5,000."
Use "for" when something is being done to benefit something or someone else.