William E. Foster was born on August 5, 1844, in Weston, Vermont, to Solomon and Martha Foster. His father was a currier who owned $50 of personal property by 1860. The family moved to Charlestown, Massachusetts, in the 1840s and then to Abington, Massachusetts, in the 1850s.
He enlisted in the Union army on August 11, 1862, and he mustered in as a private in Company G of the 12th Massachusetts Infantry later that day. The regiment took part in the Second Battle of Bull Run, the Battle of Antietam, the Battle of Fredericksburg, the Battle of Chancellorsville, and the Battle of Gettysburg. He was wounded at Gettysburg on July 1, 1863. Union officials transferred him to Company F of the 24th Veteran Reserve Corps on March 13, 1864, and he mustered out on June 25, 1864.
He returned to Abington after the war, and he married Abbie Rachel Lane there on September 29, 1866. They had at least four children: Martha, born around 1868; William, born around 1871; Minnie, born around 1874; and Nettie, born around 1877. They lived in Abington, and Foster worked in a shoe factory. They moved to Rockland, Massachusetts, in the 1870s. He applied for a federal pension in July 1879 and eventually secured one. He was unemployed for three months in 1879. He died in Rockland, Massachusetts, on December 8, 1894.