1.
will; testament; last letter
A document left behind by a deceased person, expressing their final wishes, instructions, or messages to the living.
遺書を書き残す。
To leave behind a will.
祖父の遺書が見つかった。
My grandfather's will was found.
遺書には家族への感謝の言葉がつづられていた。
The will contained words of gratitude to the family.
2.
suicide note
A note or letter left behind by a person who has taken their own life.
遺書は残されていなかった。
No suicide note was left behind.
机の上に遺書が置かれていた。
A suicide note had been placed on the desk.
警察は遺書の内容から自殺と断定した。
The police determined it was suicide based on the contents of the note.
The legal term for a will is 遺言/遺言書 (or 遺言 in everyday speech), which specifically deals with the distribution of property. 遺書 is broader — it can be any final written message, including personal letters and suicide notes. Common collocations: 遺書を書く (to write a will/note), 遺書を残す (to leave behind a note), 遺書が見つかる (a note is found).