The phrase is derived from the pre-Civil War practice of distributing salt pork from huge barrels to the slaves. By the 1870's, congressmen were referring to regularly dipping into the "pork barrel" to obtaining funds for popular projects in their home districts.
During the war of 1812, a successful New York pork packer named Uncle Sam Wilson shipped a boatload of several hundred barrels of pork to U.S. troops. Each barrel was stamped "U.S." on the docks, and it was quickly said that the "U.S." stood for "Uncle Sam," whose large shipment seemed to be enough to feed the entire army.
"No man should be allowed to be President who does not understand hogs."