The difference between the sentences is not in the meaning but in the construction This concerns "the dative shift" - see https://en.wikipedia.org/wiki/Dative_shift.
The difference centres on the double object construction (DOC) and the oblique dative (OD)
Taking much from that article:
*He said to me something.
To say is strongly monotransitive but has an optional adverbial complement.
He said something.
He said something quietly.
He said something about her.
He said something to her.
The object of "to say" is always the actual words or a description of what is/was/will be said. It can have no other object.
1 .....He.......said.................to me........................[that he was happy]
1a Subject....Verb....complement (adverbial)...[object = content clause..]
2a .....He.......said.........[……something]…..........to me.
2b .....He.......said.........[……something]…...about the decision.
2c Subject....Verb ....[........object...........]...complement (adverbial)
There are verbs that have a mandatory adverbial complement - consider
1 *He put.
2 *He put it
3 He put it down/up.
4 He put it to me/over the door/outside.
There are other verbs that have an optional adverbial complement:
5 He gave
6 He gave freely
7 He gave it
8 He gave it freely.
9 He gave it to her.
10 He gave it to her freely.
11 He gave me the book - not you. (acceptable)
12 He gave to me the book - not you. (archaic/poetic)
13 He gave to me the book - not to you. (archaic/poetic)
14 He gave the book to me - not you.
15 He gave the book to me - not to you.
16 He gave the book me - not you. (irregular/informal)
17 He gave the book me - not to you. (irregular/informal)
11 is acceptable where the context is unambiguous. It is unlikely that anyone would give another person to a book, and, if that was what was meant, it would be expressed clearly.
However: "The king gave him her" would have to have context, and would, in any case, be unlikely to be used.
.....He.......gave....[the book].................to me
Subject....Verb ....[..object..]... complement (adverbial)
.....He.......gave.........[......me/John...........]......[the book] (acceptable where the context is unambiguous)
Subject....Verb .........[dative substantive..].......[object] (Oblique dative)
Subject....Verb ......[complement (adverbial)]..[object]
The dative implies a "to" or "for" to the substantive; this then produces a prepositional modifier.
It would seem that
(i) all indirect objects are adverbial complements but
(ii) not all adverbial complements are indirect objects
(iii) that adverbial complements may be mandatory or optional.
(iv) The perceived difference is that the adverbial complement is more closely associated with the verb than the indirect object, and
(v) to has the nuance of movement about it. For has the nuance of benefiting.
It is clear that the following adverbial complements are not indirect objects:
He rode his horse to London
The water changed to ice
The horse turned to the left.
POSITION
1a He said nothing to me.
1b To me, he said nothing.
1c He, to me, said nothing.
1d He said, to me, nothing.
2a He said nothing about the matter.
2b About the matter, he said nothing.
2c He, about the matter, said nothing.
2d He said, about the matter, nothing.
In both cases, a and b are natural, but c and d are "clunky"
"He gave me the book", might seem wrong for two reasons
1. "the book" indicates a previously mentioned book. "He gave me a book" is perfectly normal, as is "He gave me the book that he had stolen."
2. There appears to be two direct objects.
The missing "to" gives the appearance of two direct objects. However, the disappearing preposition is something that English accepts:
Answer me + Answer this question = "Answer me this question", -> "Answer for me this question"
Ask John + Ask a few questions = "Ask John a few questions", -> "Ask a few questions of John."
Strike him + strike a heavy blow = "Strike him with a heavy blow", or "Strike a heavy blow at him.
Compare also
He gave the cake to her for her birthday
He made the cake for her for her birthday
He gave the cake to her willingly
He made the cake for her willingly
He gave the cake willingly to her
He made the cake willingly for her
To her / for her birthday are simply two prepositional phrases
But
*He gave the cake for her birthday to her.
*He made the cake for her birthday for her.