Cooper entered West Point at age 15 and graduated in 2 years (the customary period of study in that period) in 1815, ranked 36 out of 40 in his class. . He was commissioned a 2nd lieutenant in the U.S. Light Artillery. In 1827, he married Sarah Maria Mason and became the brother-in-law of future Confederate diplomat James M. Mason and later the father-in-law of Union Gen. Frank Wheaton. Sarah's sister, Ann Maria Mason, was the mother of
Confederate cavalry Gen. Fitzhugh Lee, the nephew of Gen. Robert E. Lee.
Cooper served in a number of artillery units until 1837, when he was appointed chief clerk of the U.S. War Department. In 1838 he received a brevet promotion to major and was appointed Assistant Adjutant General of the Army. Nine years later, with a brevet as Lieutenant Colonel, he served in the same capacity. His service in the Seminole War of 1841–42 was a rare departure for him from Washington, D.C. He received a brevet promotion to Colonel for his War Department service in the Mexican War, and was promoted to the permanent rank of Colonel in the Regular Army and Adjutant General on July 15, 1852.
At the outbreak of the Civil War, Cooper's loyalties were with the South. His wife's family was from Virginia and he had a close friendship with Pres. Jefferson Davis, who had been Secretary of War. He resigned his commission on March 7, 1861, and traveled to Montgomery, Alabama, to join the Confederate Army. He was immediately given a commission as a Brigadier General and served as the Adjutant General and Inspector General of the Confederate Army, a post he held until the end of the war. As of May 16, 1861, he was promoted to full general in the Confederate Army, one of five men promoted at that time, and 1 of only 8 men in the war, but with the earliest date of rank. Thus, despite his relative obscurity today, he outranked such luminaries as Gens. Albert S. Johnston, Robert E. Lee, Joseph E. Johnston, and P.G.T. Beauregard. He reported directly to Davis. He became the highest ranking Confederate general during the Civil War.
Cooper's last official act in office was to preserve the official records of the Confederate Army and turn them over to the United States government, where they form a part of the "Official Records", "The War of the Rebellion: a Compilation of the Official Records of the Union and Confederate Armies", published starting in 1880.
After the war, Cooper was a farmer at his home, "Cameron", near Alexandria, Virginia. The house had been taken over by the U.S. government during the war and turned into a fort, but he was able to move into what had been an overseer's house. He died at his home near Alexandria and is buried there in Christ Church Cemetery.