"Amazing Grace" was written by the English clergyman John Newton in 1779 and became a bagpipe standard.
Film composer James Horner had concerns with the use of "Amazing Grace", which he considered the major musical problem of the film. "I never wanted to use it [...] I begged, begged, 'Please don't make me use 'Amazing Grace.' It was the only battle in the film I lost. They all seemed to feel that 'Amazing Grace' was the only thing to make them happy. It was 15 seconds – I just did it. It had already been shot, and I had to match it," Horner explains, "Then I had the additional problem: Would I continue the bagpipe music outside the ship or would I switch to orchestral music? My feeling was to do something very ethereal."
He continues, "The bagpipes were the wrong move. They sound like bleating goats. What you heard in the film originally was just the bagpipe alone. Now [Paramount] had a problem in the previews with people laughing at the sound. The producers wanted the sound changed. The only thing I could do about the curse of the bagpipes was put in a cue. It starts where there's a pause as Kirk's talking – 'Of all the people I have met in my travels, he is the most Human.' There, the music came in. I had this strange chord that hangs over the whole scene; it did quite a bit, but doesn't solve the problem completely, because you still get people laughing at the bagpipes. It was, perhaps, a slight miscalculation, but it's one of those things that you're not going to know if it works until you do it with an audience." (Starlog #63, October 1982, p. 22)
According to producer Harve Bennett, "Paramount's most nervousness concerned the bagpipes." In explaining his choice of the piece, he recalled a funeral he attended for a close friend – a British government official – the year prior to his involvement in Star Trek. "At the end of the service, a lone bagpiper walked down the aisle to the nave, turned, and played 'Amazing Grace' [...] And I have never recovered from that." Upon learning the significance of the music from several British officers present, which was described to him as a traditional Scottish burial tune, he recalled, "As I was sitting there writing this funeral [for Spock], I said, 'Well, what have moved me the most in the last year?' And then I thought, 'Scotty's there!' [...] So to that end, I stand on the fact that it is not a Vulcan funeral; this is Scotty's contribution."
While acknowledging Horner's resistance to the idea, Bennett convinced Horner to transition into the full orchestra playing "Amazing Grace," explaining, "It may be corny, but sometimes corny is exactly the right choice," as the transition helps ease the audience's transition from "inner to outer space." (Starlog #68, March 1983, p. 48)