A will is a legal document drawn up by an individual to specify how their affairs should be handled following that individual's death. A will specifies the disposition of property, how any minor children will be taken care of, and can specify the final disposition of a person's remains as well.
In a time line where Captain James T. Kirk and Lieutenant Commander Mandala Flynn were assassinated by Georges Mordreaux, Leonard McCoy reviewed the wills of Captain Kirk and Lt. Commander Flynn. Flynn's will was a simple document that provided for her own funeral, and specified that she be buried on a class-M planet. Kirk's will was encoded on a permanent memory cell. Kirk's will named McCoy as the executor of his estate, specified that he was not to be kept alive in the event of brain death, and also expressed a desire to be cremated. Kirk left most of his assets in trust for his nephew Peter Kirk. (TOS novel: The Entropy Effect)
In 2284, Captain Spock's will specified that he was not to be returned to Vulcan in the event of his death. Respecting that wish, Admiral James T. Kirk buried Spock in space above the Genesis Planet after Spock sacrificed his own life saving the USS Enterprise (NCC-1701). (TOS novelization: Star Trek II: The Wrath of Khan)
In 2374, Captain Charlie Reynolds had the wills of several crewmembers of the USS Centaur placed aboard the Bernadine Cook, which was to take them to Starbase 375. (DS9 novelization: ...Sacrifice of Angels)