The Phantom Piper was the McCrimmon clan's equivalent of the Grim Reaper. It was said to be a McCrimmon himself and appeared right before a McCrimmon died. When on the Moonbase in 2070, Jamie mistook a Cyberman for the Phantom Piper. (TV: The Moonbase)
The Phantom Piper was also known as the "King of the Dreamspace", and existed in the dreams of soldiers in every war, including Troy, Culloden, and the Somme. He said he was "the only one listenin'" when soldiers cried out at night. He got a physical body outside of the Dreamspace when he tricked the Twelfth Doctor into bringing the TARDIS, which had a code carved into it, to Alan Turing on the Moon, who used Block Transfer Computation to translate the code. The code breaking unwittingly made the Piper, who was a part of the code, manifest.
The Piper kidnapped Chiyoko and used her mind, along with the centuries of slaughter locked inside, to bring mathematical constructs of soldiers from every war into existence using Block Transfer Computation. The Piper intended to shift the blame for the carnage on the sleepwalking Galateans he was controlling through their dreams, where they imagined they were in a war zone. Alan subsequently tricked the Phantom Piper into shooting a Block Transfer Computation construct of Alan which Alan created. This allowed Alan to break down the code of the Piper's construct and the soldiers he created using the bullet, which was a piece of the Piper. (COMIC: The Phantom Piper)
Unbeknownst to the Doctor and Bill Potts, the Piper was sent by Absence, working alongside Fey Truscott-Sade, to steal the knowledge of the entire space/time vortex from Chiyoko, and use it as part of a wider plan to defeat the Doctor. (COMIC: The Clockwise War)