The Flesh was a living substance used by humans to create clone workers known as Doppelgangers ("Gangers" for short) for dangerous labour.
History
Considered "the government's worst-kept secret", the Flesh was programmable matter that was often used in dangerous industrial work, to create clone bodies operated by human "drivers". Through the Flesh, thousands of lives were saved due to the worker's Doppelganger being killed in the place of the Human operator.
The Flesh was even able to self-replicate, meaning there was never a risk of work forces running out of it.
When the Eleventh Doctor met the Flesh in the 22nd century, he cryptically claimed to have met it previously.
In the 22nd century, a solar storm caused a group of active Gangers to be separated from their human controllers. Rather than reverting to Flesh, as they were programmed, the Gangers operated independently of the humans, though they still had the memories of the Humans that they were based on. After failed peace attempts with the Humans, the Gangers rebelled because they wanted the right to exist. Later the Flesh created a Ganger of the Doctor on its own, without human manipulation or assistance, having used the sample it took from the Doctor's handprint and the psychic contact it made with him.
Sentience
While humans acknowledged the fact the Flesh was alive, they did not consider it a sentient or even intelligent life form, comparing it to moss. Miranda Cleaves explained that the Flesh only knew how to mimic life, but did not actually know how to be alive.
The Doctor, on the other hand, was not so sure. When he scanned the Flesh with his sonic screwdriver, he was surprised to note that it responded with an attempted scan of its own. When he touched the substance he noted that he felt a consciousness in the flesh that curiously investigated him when he made contact. He told the others that the Flesh might have a consciousness of its own, but not one that humans could understand; each time they made clones it learned more and more about humans.
The Doctor eventually discovered through his own Ganger as well as the others that the Flesh indeed possessed a sentience of its own that it was only just beginning to actualise. It was currently in great pain due to its ability to recall the deaths of the Gangers born from it. This was evident during Ganger decommissioning when the Ganger's eyes would ask "Why" because of the decommissioning.