The Gospel of Thomas was discovered at Nag-Hammadi in Upper Egypt in 1945 as one of numerous so called gnostic texts.
Gnostics were followers of a variety of religious movements in the early christian centuries and they stressed that people could be saved through a secret knowledge (a gnosis in Greek). Their beliefs are well documented in the Christian literature of the second century and Gnostiscism was considered to be a heretical perversion of Christianity.
In Gnostic belief, there is a sharp dualism, they set a transcendant God over against an ignorant creator. All Gnostics viewed the matieral creation as evil. Sparks of divinity however, have been encapsulated in the bodies of certain "spiritual" individuals destined for salvation.
These "spirituals" are ignorant of their heavenly origin and God sent them a redeemer to bring them salvation in the form of secret knowledge of themselves, their origin and destiny. Thus awakened, the spirituals escape the prison of their bodies at death and pass safely through the planetary regions controlled by hostile demons, to be reunited with God.
Since they believed that salvation depended upon the knowledge of one's spiritual nature, many acted in extremely indulgent and licentious behaviour, claiming their "sins" could not stain them in any way. They also held to creation of woman being the source of all evil, and having children simply increased the number of souls in bondage to the powers of darkness.
It offered explanations of the evil of the world and mankind annd a way of escape and was a great success, especially on the fringe of Christian society.
The knowledge of the Gnostics was known mainly through the writings of the great Christian apologetics such as Origen and Tertullian, however, in the 19th century and beyond, manuscripts were published which include such writings as
Gospel of Mary Magdalene, Acts of Peter, Wisdom of Jesus and Apocryphon of John.
in 1946 as previously mentioned, a priceless cache of twelve coptic codices and fragments were discovered in upper Egypt. This collection dates to AD 400.
The Gospel of Thomas is an important collection of 114 sayings attributed to Jesus. They are included in the Latin Vulgate as one of the Apochryphal books accepted by the Roman Catholic Church. Apocryphal and pseudepigraphal literature was apparently intended either to supplement or supplant existing canonical literature. Many of the apocryphal gospels offer guesses as to what occurred during the so-called "missing years" of Jesus' life -- during his childhood or after his resurrection. Others attempt to provide support for later theological convictions -- both orthodox and heretical. In the case of the acceptance of the Gospel as Canon in the RC Church, remember the Reformation was in full swing when the Council of Trent took place in 1546, and the acceptance of the Apocryphal Books against even the better judgement of many Roman Catholics at the time, was a reaction to the Reformists insistence on the historic and closed 66 books of the Canon of Scripture.