Born in Hanover, New Hampshire, on December 26, 1819, Foster graduated from Dartmouth College.
In 1849, Foster and a group of friends planned to move farther west, but did not make it to California due to a cholera outbreak.
Instead, Foster settled in Washington County, Iowa, where he worked as a farmer and lawyer.
During his legislative tenure, Foster helped pass several bills related to educational causes.
Foster joined the 11th Iowa Infantry Regiment on April 21, 1861, was successively promoted to captain on October 1, 1861, and major on September 1, 1862.