Why is it correct to say "He came and said something to me" but not "He came and said to me something"?

Say is a bitransitive verb, which means it takes two object phrases.

One is the person addressed (the Indirect Object), and the other is what was said (the Direct Object).

Most bitransitive verbs govern the Dative Alternation. This means that the two objects can appear in two different orders, ad lib, without any meaning difference. In one variant, the Indirect Object appears with a preposition to; in the other the order is reversed and there is no preposition.

  • Subject - Verb - Direct Object - to Indirect Object
    • He gave the book to me. ~ They threw the ball to her. ~ They told something to her.

but these are not grammatical:

  • *He gave the book me. ~ *They threw the ball her. ~ *They told something her.

or

  • Subject - Verb - Indirect Object - Direct Object
    • He gave me the book. ~ They threw her the ball. ~ They told her something.

but these are not grammatical:

  • *He said to me something. ~ *He gave to me the book. ~ *They told to her something.

However, say does not govern the Dative Alternation (although tell does -- that's one of the differences between them), and therefore the first alternant is the only way that both objects can appear with say. Thus it's ungrammatical to say

  • *He said me something.

English is a word-order language. When the verb (say) is transitive (takes a direct object [DO]: "something" in this sentence) and the indirect object [IO] is in a prepositional phrase ("to me" in this sentence), the grammatically correct word order is:

said something to me.

It's not standard English to say He said me something, but it is standard English to say He told me something. This suggests either that the verb in your sentence is actually a phrasal verb, (say to, but my Collins Cobuild Dictionary of Phrasal Verbs doesn't include it, nor does any Web page on phrasal verbs) or that say doesn't have the same usage rules as tell.

The verb give is like tell in that respect: Both

He gave something to me ~ He told something to me

and

He gave me something ~ He told me something

are grammatically correct. The pattern is S+V+DO+to+IO or S+V+IO+DO.

Once you add a complement to something, the relative clause that I'll never forget, the usage rule changes and "said to me something (that) I'll never forget" is grammatical and acceptable because of the desirability of placing the (reduced, i.e., minus the relative pronoun that) relative clause immediately after the noun phrase it modifies.

The sentence "He came and said to me something I'll never forget" seems to me a bit of a style problem. I'd change said to me to told me or just to said without the to me, unless context demanded said to me.

"He came and told me something I'll never forget"
"He came and said something I'll never forget"

Ultimately, with the relative clause, it's a style and usage question. Without the relative clause, it's a grammar question (deleting the preposition to is necessary).

I'd also probably insert over between came and and.