Indirect Object Pronouns

When a pronoun takes the place of the name of the indirect object, use the following pronouns:

me (me)
te (you-familiar)
le (him, her, you-formal)

nos (us)
os (you-all-familiar)
les (them, you-all-formal)

In an affirmative statement with one verb, the indirect object pronoun comes immediately before the conjugated verb.

Juan me compra un regalo.
John buys me a gift.
John buys a gift for me.

Juan te compra un regalo.
John buys you a gift.
John buys a gift for you.

Juan le compra un regalo.
John buys her a gift.
John buys a gift for her.

Juan nos compra un regalo.
John buys us a gift.
John buys a gift for us.

Juan os compra un regalo.
John buys you-all (familiar) a gift.
John buys a gift for you-all.

Juan les compra un regalo.
John buys them a gift.
John buys a gift for them.

The IO pronouns le and les present a special problem because they are ambiguous. That is, they can stand for different things.

le
to (for) him
to (for) her
to (for) you-formal

les
to (for) them
to (for) you-all-formal

The following sentences, while grammatically correct, are ambiguous:

Ella le escribe una carta.
Ella les escribe una carta.

Out of context, there is no way we can know the meaning.

Ella le escribe una carta.
She writes him a letter.
She writes her a letter.
She writes you (formal) a letter.

Ella les escribe una carta.
She writes them a letter.
She writes you-all (formal) a letter.

Since le and les can mean more than one thing, a prepositional phrase is often added to remove the ambiguity.

Ella le escribe a Juan una carta.
Ella le escribe a su hermana una carta.
Ella le escribe a usted una carta.

Ella les escribe a sus padres una carta.
Ella les escribe a ustedes una carta.

Sometimes a prepositional phrase is added not for clarity, but rather for emphasis.

Juan me da a mí el dinero.
John gives me the money.
(emphasizing that the money is given to me and not to someone else)

Juan te da a ti el dinero.
John gives you the money. (emphasis on you)

There is no ambiguity in the following sentence. It can only mean one thing.

Juan me da el dinero.
John gives me the money.

The addition of a prepositional phrase merely adds emphasis.

Juan me da a mí el dinero.
John gives me the money.

(Studyspanish.com)