Black codes were laws enacted in the Southern United States after the Civil War that aimed to restrict the freedoms of African Americans and ensure their availability as a cheap labor force. These codes were established during the Reconstruction era as a means for white Southerners to regain control over former slaves and maintain a social order similar to that which existed before the war. They significantly impacted the social and political landscape, leading to resistance movements and further legislation.