William Shakespeare King was born on December 28, 1810, in Chester County, Pennsylvania. He joined the United States Army on July 29, 1837, receiving an appointment as an assistant surgeon. He took part in the Second Seminole War and the Mexican American War, and he was promoted to surgeon in August 1856. In the early 1860s, he was stationed in the New Mexico Territory.
He remained in the army during the Civil War, and he received an appointment as a medical director in the Army of the Potomac. In October 1863, army officials transferred him to the Department of the Susquehanna. He remained there until March 1864, when he became superintendent of hospitals in Cincinnati, Ohio.
He married Virginia Evans on May 22, 1867, and they had at least two children: Gertrude, born around 1871; and Edward, born around 1874. He received the rank of lieutenant colonel in June 1876 and colonel in March 1880, and he retired on June 30, 1882. After retirement, he divided his time between Philadelphia, Pennsylvania, and Asbury Park, New Jersey. He died in Asbury Park on August 2, 1895.