I have a last doubt.

According to your exlanations:

I gave him the book/or the book to him.
BUT
I wrote him the letter(or the letter to him.
BUT
I wrote to him. (is also possible)
She explained to me how to get there.

Yes, all the variations are correct.

Just remember that if there's a preposition, there's a prepositional phrase. If there's no preposition, then there's an indirect object in these expressions.