"Take This Hammer" is a prison, logging, and railroad work song, which is similar to some other folk songs and shares verses with them. Together, this group of songs are referred to as "hammer songs" or "roll songs" (after a group of wheelbarrow-hauling songs with much the same structure, though not mentioning hammers).
For almost a hundred years after the abolition of slavery, convicts, mostly African American, were leased to work as forced labor in the mines, railroad camps, brickyards, turpentine farms, and then on road gangs of the American South. Forced labor on chain gangs, levees, and huge, plantation-like prison farms continued well into the twentieth century. It was not unusual for work songs like "Take this Hammer" and its "floating verses" to drift between occupations along with the itinerant laborers who sang them.