Sentences 1 and 2 are both grammatically correct. In Sentence 1, the dreamer dreamed that his best friend died only recently, hence the use of the present perfect "has died." In Sentence 2, the dreamer dreamed that his bets friend died at some unspecified time in the long past or in the not so recent past, hence the use of the past perfect "had died."
Sentence 3 is grammatically incorrect because it uses the wrong plural form "have died" for the clearly singular "best friend." It should use the singular "has died" or "had died" instead, observing the conditions specified in Sentences 1 and 2.