D. H. Hill was born at Hill's Iron Works, in York District, South Carolina to Solomon and Nancy Cabeen Hill. His paternal grandfather, Col. William "Billy" Hill, was a native of Ireland who had an iron foundry in York District where he made cannon for the Continental Army. His maternal grandfather was a native of Scotland. Hill graduated from the United States Military Academy in 1842, ranking 28 out of 56 cadets, and was appointed to the 1st United States Artillery. As an infantry officer he distinguished himself in the Mexican–American War, being brevetted to captain for bravery at the Battle of Contreras and Churubusco, and brevetted to major for bravery at the Battle of Chapultepec. Among the slaves owned by the Hill family during Daniel Harvey's youth was Elias Hill, whom Daniel Harvey helped teach to read and write and who later became a preacher and led his congregation in emigrating to Liberia.