The Holy Trinity is one of the “great mysteries” of the Christian Church. What this usually means is that no attempt at explanation makes sense, not to the speaker nor even to those who formulated a given doctrine. The Christian doctrine of the Holy Trinity, defined at the Ecumenical Councils of Nicaea (325 CE) and Constantinopolis (381 CE), did not simply erupt in the 4th century. Its antecedents lie at least as far back as the early Hellenistic period.
Contrary to the myth of Patrick of Armagh using a shamrock to teach the poor, ignorant, simple Irish about the Trinity, the reverse is more likely. The Irish pantheon had several trinities, most notably the battle goddesses Macha, Badb, and Nemain, who collectively made up the battle goddess Anann, better known as The Mor Rhioghan, or Morrigan, the Great Queen. My putative ancestor Tuireann Delbaeth (Delbha na Aodh, “Producer of Fire”) mac Ogma of the Tuatha De Danaan begot not only the Morrigan trinity but two others as well: the smith trinity of Creidne, Luchtaine, and Giobhniu and the male war and fertility trinity of Brian, Iuchar, and Iucharba.
Isis and some of the other Great Mothers of the Mediterranean and West Asian world had three forms also: as a virgin, as a mother, and as an old woman. These existed not linear in time but simultaneously throughout the sphere that is spacetime. Some writers have even speculated that this is the framework behind the three separate Marys (Mary Magdalene, Mary the mother of Jesus, Mary the mother of James) reported in the Gospels to have visited the tomb of Jesus on the first day of the week following the Crucifixion.
The Mystery Cults in this wide region likewise had their own trio of figures in what could be seen as a “Trinity”. For example, Isis, again, formed a trinity with Serapis (a syncretic deity merging the Egyptian Osiris and Apis with the Greek Asclepius) and their son Harpocrates (a Hellenistic form of Horus). There were others such trinities for the Mystery Cults of Mithras, Dionysus, Adonis, Attis, etc. The Mystery Cults, or rather Mystery Cult, was not so much a continuation of the classical national religions as a new form of religion adapting clothing from these older religions and thereby taking on local peculiarities.
Jews and Samaritans of the Diaspora already formed the overwhelming majority of Hebrews in the world at the beginning of the 1st century CE. Of the 4-4.5 million Hebrews then alive, only 500 million (roughly 250 million each) lived in Palestine. The rest were scattered throughout the Hellenistic world, save the four groups in the southern Arabian peninsula.
In the thought of the more traditional teachers of Judaism (not sure about Samaritanism at the time; currently all the old hypotheses are being tossed out), a sort of proto-Trinity had begun to form. Proto- rather than full because what might or would later become the full-blown Trinity of the Christian Church remained in Jewish thought a single Godhead with emanations. Two were universally recognized among Jewish theologians and philosophers.
First, the Memra, or D’var (Word, in Aramaic and Hebrew), was considered to be that through which God created the Universe and exerted his power. The Memra in Jewish thought, perhaps at the time though probably later, was identified with Hokhma (Wisdom).
Second, the Shekhinah (“Presence”), was equated with the Yekara (“Glory”) of God, and later also identified with the Ruach ha-Kodesh (“Holy Spirit”).
Among Hellenistic Jews, most notably Julius Philo Judaeus of Alexandria, adapted the Stoic concept of Logos to Jewish philosophy, equating the Logos with the Memra (the two terms both mean “Word”, after all). In other writings, he equated the Ruach ha-Kodesh with the Hellenistic concept of Sophia (“Wisdom”) and therefore with Hokhma while his uniquely Jewish concept of Logos he identified with Binah (“Reason” or “Understanding”).
I don’t know of anyone having traced the development of thought regarding the Christian Trinity directly from these three main sources (Mystery Cults, Palestinian Judaism, Hellenistic Judaism) through its getting mixed up with Gentile Hellenistic philosophies such as Neoplatonism to the afore-mentioned Ecumenical Councils. But should that ever happen, I would be very interested to see it.
These ideas, while widespread, are not universal among Jews, then or now, though all consider the Shekhinah or Ruach ha-Kodesh feminine, as was Sophia by ancient Greeks. So too is Binah, incidentally. Some Jewish philosophers, in contrast to the above, equate Memra with Shekhinah. For Moses Maimonides, the preeminent philosopher and theologian produced by the Sephardic Jewish community in Al-Andalus and later of Alexandria, Egypt, the Shekinah, Memra, Yekara, and Logos were all separate and equal emanations of the One God.
Doctrine of the Holy Trinity in the Early Church:
The sole explicit mention of the Holy Trinity in the New Testament comes in the Great Commission at the end of the Gospel of Matthew (28:19), in which the apostles are exhorted to baptize them “in the name of the Father, and of the Son, and of the Holy Spirit”. This is in direct contradiction to Peter’s call to the crowd in The Acts of the Apostles 2:39 to be “baptized every one of you in the name of Jesus Christ for the forgiveness of your sins”, as well as every scene in which a new convert is baptized elsewhere in the New Testament.
This and other factors argue the case that this particular passage is a later interpolation, a “pious fraud”. Were this passage in the original Matthew, Arians might have never become such a threat to the Athanasians (or perhaps the reverse was the case). Incidentally, both theologians were from the church in Alexandria, a factor that often gets overlooked in accounts of the whole controversy that led to the First Ecumenical Council at Nicaea in 325 CE.
Another factor is that no Early Fathers talked about it. The first to mention anything related to the Trinity was Justin Martyr, around 110 CE, when he exhorted “obedience to Christ, and to the Father, and to the Holy Spirit”. The correct three “persons”, but not exactly a Trinitarian formulation either. In the later 2nd century, Theophilius of Antioch was the first to use the word “Trinity”, which he defined as God, his Word, and his Spirit. Tertullian, later declared a heretic, was the first important apologist for the Doctrine of the Trinity as the Father, the Son, and the Holy Spirit in an early 3rd century dispute with a theologian named Praxeas, who advocated the doctrine of monarchianism, which opposed division of the Godhead into different persons.