Each boy was given a toy as a parting gift which made him|them happy
In this sentence which one should be correct "him" or "them" as it qualifies the distribute pronoun 'each'?
Both are correct but mean different things.
Each boy was given a toy as a parting gift which made him happy.
"Him" is singular and the most reasonable noun for it to refer to (called the antecedent) is "boy". Thus, this sentence states that "each boy was happy".
Each boy was given a toy as a parting gift that made them happy.
"Them" is plural and there are no plural nouns available to be its antecedent. Consequently, it is not clear what "them" refers to. Hearing this sentence with no context, I think the most reasonable interpretation is that "them" refers to the unstated givers of the toys. So, unlike the first sentence which clearly states that the boys were happy, this sentence sounds more like the givers of the toys were happy.
There is a tendency in uncarefully spoken English to use the plural pronoun "them" in places where the singular pronouns "him/her" are proper. The two most common situations I can think of off the top of my head are:
The gender of the antecedent is not known and the speaker believes the lack of clarity is acceptable. Situations like this usually involve an implicit understanding between the speaker and listener (perhaps conveyed by mannerisms or tone ) that you are using the word "them" incorrectly as a placeholder until the correct "him/her" can be determined. Because the "incorrectness" is known to both parties, the meaning becomes clear.
The antecedent is singular grammatically but refers to something plural in the speaker's mind. Your sentence for example falls into this category. If the speaker stated "each boy" but was thinking of "all the boys" as a collective group, it is possible that he would misspeak and use "them". (Please note, that while what I just said is possible, in this case, it is not likely. It is not likely because in spoken English, it is much more common to say "Every boy" or "All the boys" than "Each boy". "Each boy" sounds more methodical and intentional and makes the listener less likely to overwrite grammatical mistakes in his mind.)
Technically, "each boy" is obviously singular so the related pronoun should be "him." The example sentence, however, is badly crafted and ambiguous.
If what was intended was "All the boys were pleased because each one was given a toy," many people would say "them." The focus of this thought is that all were happy. Notice that the intended sentence is perfectly logical and that the difference in the number of the two verbs is both grammatical and consistent with that logic. But you can say the same thing with "Each boy was made happy because each was given a toy."
However, the example sentence may have meant "Though each boy received a different toy, each boy was pleased by the one given to him." In that case, the focus is as much on the individual boy as the group of boys, and consequently people would be very unlikely to use "them" instead of "him."
In the given sentence, "them" is technically wrong, but many people would use it if their focus was on the group. Speech is filled with minor variations from perfect grammar as people edit themselves in real time.
In writing, where there is time to edit, the grammatical error should indicate a need to recast the thought. The example sentence is badly drafted. What are we trying to say: "Though each boy received the same toy as a parting gift, all were pleased" or ""Each boy received as a parting gift a toy that pleased him." You can't make that kind of distinction based on the number of boys involved.