Jonathan Edwards' Ontological Argument
In his "Essay on the Trinity" (and private notebooks and public sermons), Jonathan Edwards suggested a form of ontological argument for each of the three persons of the Trinity. Anselm's argument starts from a definition of a hypothetical God who perfects all excellences and proceeds to show God must actually exist since existence is an excellence that God must have perfected. Edwards argues along the same lines for each Person of the Trinity:
And this I suppose to be that blessed Trinity that we read of in the Holy Scriptures. The Father is the Deity subsisting in the prime, un-originated and most absolute manner, or the Deity in its direct existence. The Son is the Deity generated by God's understanding, or having an idea of Himself and subsisting in that idea. The Holy Ghost is the Deity subsisting in act, or the Divine essence flowing out and breathed forth in God's Infinite love to and delight in Himself. And I believe the whole Divine essence does truly and distinctly subsist both in the Divine idea and Divine love, and that each of them are properly distinct Persons.
The Father perfects existence
Edwards did not seem to make the ontological argument with respect to the Father (though it is that Person normally called simply "God"). Instead, he follows Aristotle in considering the Father to be the prime mover or cause (in all senses) of all that exists. If you've ever played the "why" game with a toddler (Q: "Why does the sun shine in the morning?" A: "Because the Earth rotates." Q: "Why does the Earth rotate?", etc.), you know that the ultimate answer is always God. (If you don't happen to believe in some prime being such as God, the ultimate answer must be "Because that's the way things are.") Even the Son, who is conceived by the Father, and the Spirit, who proceeds from the Father, depend on the Father for existence.
The Son perfects understanding
Edwards assumes that the Father's end is to enjoy Himself and that in order to accomplish that, He must have an "image" or idea of Himself. The image must be distinct from the Father; it must be the object of God's affection. If the image is worthy of God's infinite enjoyment, it must also be perfect in representing God. Fundamentally, the Father's imagination is so powerful that He creates the Son. In fact, Proverbs 8 describes how God fathered Wisdom, which is just another way to represent the understanding of God, before the Creation.
The idea is not that different from what we mean by "a gleam in your father's eye". God contemplates Himself and the Son is that image. Unlike our imaginations, which remain safely in our minds without some sort of effort, God's understanding of Himself is made manifest. The Son existed before He was incarnated as Jesus because God has always been delighting in Himself. Edwards argues that a duplicity is necessary for God to be the object of His own delight.
The Spirit perfects action
Finally, the Spirit is the manifestation of God's own affection for Himself. Now it must be admitted that this is certainly a strange Person. But Edwards argues that this is exactly the sort of Person we see in the Bible. He concludes from 1 John 4:8, which states that God is love, that the embodiment of the love between the Father and the Son is the Spirit. We note, in passing, that Edwards affirms the filioque because the love, delight, honor, glory, and so on between the First and Second Persons is mutual.
According to Edwards, these are not feelings, but actions. The interaction between Father and Son is also perfect, so like God's understanding of Himself, it too is manifest as the Third Person. The essay notes that Paul passes on grace, peace, and mercy from the Father and Son, but never the Spirit. In addition, the Father and Son express their affection for each other, but never for the Spirit. One solution to these puzzles is to conclude that the Spirit is God's love.
Perichoresis
In order to explain why at least two Persons must exist, Edwards notes the (then) common notion that "God is infinitely happy in the enjoyment of Himself". From that idea, he deduces:
However, if God beholds Himself so as thence to have delight and joy in Himself He must become his own object. There must be a duplicity. There is God and the idea of God.
The argument is philosophical, by the way, not grammatical, as it marries the ontological argument with the conception of God's self-enjoyment. Edwards was not the first to extrapolate that the Spirit is the action of love between the Father and the Son:
If, as is properly understood, the Father is he who kisses, the Son he who is kissed, then it cannot be wrong to see in the kiss the Holy Spirit, for he is the imperturbable peace of the Father and the Son, their unshakable bond, their undivided love, their indivisible unity.—St. Bernard of Clairvaux, in Sermon 8, Sermons on the Song of Songs
Of course, these are mere illustrations of the intimacy (perichoresis) that the members of the Trinity enjoy. Going back to Paul himself, Christians have wrestled with this great mystery.
Conclusion
Jonathan Edwards was the first to point out that he did not propose to make the mystery of the Trinity unmysterious. The degree you accept that ideas perfected become "real" is the degree you are likely to accept this formulation. However, it does insist on exactly three Persons since it requires God to be object, subject, and verb of the sentence:
God delights in Himself.