The glass avatars were created, under the Testimony Foundation, by Helen Clay in 5,000,000,012 on New Earth. When Captain Lethbridge-Stewart's testimony was added, a timeline error caused by the refusal of both the First and Twelfth Doctors to regenerate caused the Captain to be returned to the wrong decade. To correct this error, the Testimony Foundation abducted the Doctors and the Captain by taking the Twelfth Doctor's TARDIS to their own ship. Here, the Doctors found the Glass Woman who served as the interface for the ship and the glass avatar of Bill Potts.
Upon finding out about the Testimony Foundation and its purpose, the Twelfth Doctor returned Captain Lethbridge-Stewart to nearly the time of his death. When the Doctor and Bill bid each other farewell, Bill allowed the Doctor to regain his memories of Clara Oswald in order to show that Bill's memories within the glass avatar were the same as the Bill the Doctor knew. The glass avatar of Nardole joined the two, and they all embraced before the glass avatars of Bill and Nardole teleported away. (TV: Twice Upon a Time)