Our Gemara on Amud Aleph discusses the principal of Mitzvah Lekayyem Divrei Hames, it is a mitzvah to follow he instructions and fulfill the wishes of the deceased. What is the reason for this principle?  We might consider that it is for practical reasons, in order to effectuate the legal transfer of assets without complex kinyanim or contracts, since a person who is about to die may not have the time or tools to execute a proper will and testament.  Related to this, we know the rabbis were careful not to cause distress, and to the contrary, to ease the mind of a person on their deathbed (Rambam Matanos 8:2).  By allowing the person to settle his affairs with mere verbal instruction, instead of cumbersome contracts or kinyanim, he will be more at ease.  Another possible reason is to show honor for the deceased.  It is not easy to do favors or chessed for dead people, since they have no earthly needs. Therefore, honoring their wishes is human decency. However, there may be even more powerful reasons:

Maor Vashemesh (Devarim 1) says that a regular person before death is in an elevated spiritual state, even more so a tzaddik, and thus his words and instructions are almost like prophecy and ought be taken seriously. Similarly, Abravanel (Bereishis 27:1) says that the prayers of a person before his death have unusual powers, because he is attached to Hashem.

I believe any liminal transition point in life has a special spiritual window. Thus marriage, birth, death and bar mitzvah tend to be honored by a ceremony. It’s not the ceremony that makes it holy. It is inherently holy and the ceremony simply marks it and focuses it appropriately.

There are various halakhic questions as to which kinds of post-mortem instructions are legally binding.  Regardless of the legal nature, we see that there may be powerful spiritual insights that come in the moments preceding death, and at least morally if not legally, the words of the dying should be taken with great respect.