why must you say "le escribi" instead of just "yo escribi"?
some verbs I am noticing require you put "le" in front of it. "Le escribi una carta"
"El niño le dio un pastel"
I don't understand why the sentence is structured this way or which verbs require it!
3 Answers
Le escribí una carta means I wrote him/her a letter, it is in the past preterite tense you don't have to say yo because escribí is the first person tense so yo is already stated in the verb congugation, escribí means I wrote whereas escribo is the present indicative and means I write, the le at the beginning refers to the him or her that you wrote to, hope this clears it up for you.
Ken Williams has given a great explanation as to each component of the sentence and it might benefit you to review what he has written. I just wanted to add how this relates to your other sentence:
El niño le dio un pastel
El niño/the boy - subject (noun and definite article)
le/to him - indirect object (indirect object pronoun)
dio/he (the boy) gave - verb (verb in preterite tense)
un pastel/a cake - direct object (noun and indefinite article)
All together this becomes: The boy gave the cake to him/The boy gave him the cake.
If I am not mistaken, the focus of your question was on the indirect object pronoun "le." It is very similar to the way that we would use the pronoun "to him or for him" in English, and if you still feel unclear on this you might try reading one of these reference articles regarding indirect object pronouns.
Indirect Object Pronouns (SpanishDict Version)
Like kenwilliams said, you can see more informations in the reference section