A little history lesson here: There was dissent among early Christians as to the nature and role of Christ, so the Emperor Constantine (who was not himself a Christian) held a council in which the exact nature of Jesus would be determined. The "son of God" role won out. But this presented a problem in its logic, so another council was held years later that invented the Holy Trinity... basically a "baffle them with bullshit" exercise that still is used today. The "logic" is that the concept of the Holy Trinity explains how Father, Son, and Holy Ghost can each exist as a deity while keeping Christianity as a monotheistic religion as opposed to a polytheistic religion.
Re: the origin of the trinity concept in religions:
From the life cycle of birth, procreation and death the concept of the trinity emerged. Most of the primitive races conceived a triad consisting of three forces or powers in one god. Thus the Hebrew Tribal God Yahweh manifested abilities of creation, preservation and destruction of the life force. Many centuries later these same powers, supposed to be inherent in one god, were interpreted as referring to three seperate individual dieties. As a matter of interest the Hindu Trimurti, comprises Brahma, the Father Creator, Vishnu, the Son and preserver; and Siva, the Holy Spirit and destroyer. The phallus also was a trinity, acting as one impregnating unit , although composed of three seperate and differently- functioned parts.