When I first saw the phrase "God is an imaginary friend for adults" it struck me as one of those throw-away rhetorical insults, like "Against abortion? Don't have one", that don't stand up to rigorous scrutiny. Certainly it is thrown about like an insult, to convey 1) that religion is childish, and 2) that God does not exist. The more I though about it, though, the more I like it. I'm a skeptic, and I can't accept superstitions or supernatural entities, but I can't deny the existence of God as a social phenomenon. God exists for many people. The belief exists, whether or not the object of the belief does. So whether or not you profess to believe, you have to deal with people who do.
Likewise, if you are a parent with a child who has an imaginary friend, you have to tread a rather narrow path. You shouldn't confront the child and insist the friend does not exist, but you also shouldn't "play along". When the child creates the friend, that shows imagination. If you do it with them, however, it deprives the child of the opportunity to express their imagination and work out their psychological struggles on their own. On the one hand, you don't want to let a child "get away with" trying to distance themselves from unacceptable behavior or attitude just by blaming it on the friend. On the other hand, it's the behavior or attitude you need to focus on, not the imaginary friend, so calling the child a liar or insisting that the friend does not exist only distracts from the behavior you need to deal with.
My eldest son created his "friend" (which he named Tweety) in reaction to the birth of his younger brother, and the diversion of parental attention to his infant sibling. If he would try to blame things he did on Tweety, I'd give him "The Look". The Look conveys: "I don't believe you, but I am going to give you a chance to explain yourself." I've never seen any point to telling him that his friend did not exist, or arguing with him. When people talk to me about "God" I usually take the same approach.
Let's dispense with the whole problem of "the existence" of God. Take for example, the "ontological" proof of St. Anselm. Anselm defines "God" as "that which nothing greater can be conceived" and begs us to accept the premise that it is "greater" to exist than not exist. From this it follows that "God" (so defined) exists. If you think about this proof and give it every benefit of the doubt, it can teach you a lot about the concepts of existence, "greatness" or value, "things that can be conceived" and even about the whole notion of proof. As for the role of God in the social and political phenomena of religion, however, it teaches you nothing. It does not show who or what God is, except perhaps to vaguely define God as "what we value the most". So for the unconvinced, proofs for the existence of God are pretty much useless. What's needed is a description, not a proof. The question to start with is not "Does God exist?", but rather "Who is this God?"
If God is an imaginary friend, then God is not you. Perhaps God is everything you are not. Children create imaginary friends when they are lonely or feel neglected. If you are an adult, you should by now have figured out that there is a great big world out there, that the world is not your creation or under your control, and generally speaking, the world does not revolve around you. If you think about your situation, you may feel small and alone.
People turn to God in times of stress when they are cut off from family and friends: in prison or on the battlefield, for example. If conjuring up an imaginary friend seems to you a weakness of frail people, consider the implications of Voltaire's remark: "If God did not exist, we would have to invent Him." If Voltaire is right and we do invent God, then maybe we get the God we want (or deserve)? Perhaps the power, comfort and wisdom of your imaginary friend will be in direction proportion to your own strength, enlightenment and maturity? Imagine, then, a mature and enlightened friend, not a mean and vindictive id-monster.
For the enlightened person, what purpose would this exercise of the imagination serve? To converse with our ancestors, perhaps? To engage our heritage in dialogue or dialectic?
Of course, we write stuff down. If all you want is a simple fact, you're probably better off looking it up, rather than praying to God. As your questions tend to the general, ethical and moral, however (in the vein of "What should I do?" or "How can I endure this?") encyclopedias and handbooks become less useful. You need synthesis and a holistic view.
The oldest and greatest tale of a dialogue with God is the book of Job. Job is afflicted with all sorts of misfortunes and pains, and demands an explanation from God. God replies: "How can you expect to understand? Were you there when I created the universe?" If that seems to you an unsatisfying conversation, then perhaps you can try framing the question better than Job did.
Ancient gods were usually tribal gods. The god a tribe worshiped was a reflection of themselves. If you pick up the Bible today, don't you wonder why the Jews are God's chosen people? Even if they are, why should we care? Shouldn't we be striving for a broader perspective? The perspective which views all of humanity as one tribe? That's easier said than imagined in any concrete way.
When a tribe's situation became complicated, so did its God or gods. You can read the Old Testament in this light as the story of a people's transition from a parochial tribe to a subculture in a greater world. Cultures formed from the rapid amalgamation of various tribes (Greek, Norse, Hindu) tend to reflect this history with a polytheistic pantheon. The Jews, on the other hand, went through many changes and dislocations, from slaves in Egypt to imperialists under Solomon to captive subculture under a foreign empire, but somehow maintained a distinctive identity. The Bible personifies this experience with tales of how mythic heroes (Abraham, Isaac, Moses, David, Daniel) interacted with God. When Moses frees the people from slavery and heads out into the wilderness, he must be asking himself, "Now what?" He goes up to Mt. Sinai to "talk with God" (reflect on his heritage) and decides that, now that they are no longer under the thumb of the Egyptians, he needs to set down some rules. "God" gives him ten rules (actually a lot more than that, but ten is traditional) beginning with the rule that "I am the Lord your God, thou shalt have no other gods before Me." This could be understood as a way of saying, "let's stick with what we know". Let's not forget what we've learned from this experience in Egypt. Let's preserve our heritage amidst the influences of all the other peoples we meet, and let's not adopt a shallow version of someone else's heritage.
Things start falling into place when you read the Old Testament as the Jewish tribe's attempt to tell stories that answer questions, such as "Who are we?", "Where do we come from?" and "What should we do next?". Given that the Jews have been slaves, kings and everything in between, you can probably find something in their stories which is valuable for your situation no matter who you are. African-Americans, for example, find the Old Testament a rich trove of valuable advice and encouragement for a people recently freed from slavery and living as a minority in what historically was a foreign land. Listen to Martin Luther King's "I have a dream" speech and the part where he alludes to Moses standing on the mountain top and looking down at the Promised Land. He certainly seems to understand exactly what he is talking about: the pathos of having seen the future, having helped make a better future, but knowing he will not live to enjoy it.
We live in a social world, an interdependent technological network, if you will, which could never have been created by one individual in one lifetime. And it has been this way since someone figured out a way to break pieces of flint into the shape of an arrowhead, and taught the technique to someone else. Take, for example, a light bulb. I think I have a pretty good grasp of what they are made from and how they work, but if I were dumped on a desert island, alone with no tools, I doubt I could create a working light bulb in my remaining lifetime. I'm very glad someone else took the trouble to experiment with different stuff until he arrived at some which glows nicely and doesn't burn up right away. Rome wasn't built in a day, and it took another two thousand years to go from Rome to the global civilization we have today.
If you personify our accumulated ethical wisdom as someone you can talk to, and call it "God", I don't think you'll be all that far off the mark. The question then becomes, why imagine God as a person? Why not refer to prayer as "reflection" or "contemplation" and to God as our "heritage" or as "civilization" or some other appropriate abstract noun? Consider how difficult it is to interact with an abstraction. We can break down the great mass of ancestral knowledge into bite-sized chunks like "geometry" and learn them that way, but in the long run, that is only sufficient for children. At a certain point, school days are over, and you have to deal, somehow, with the hugeness and complexity. One method is talking to your imaginary friend "God".
Jesus instructed us to address God as "Abba" ("Daddy") when we pray, not "Lord" or "Almighty God": putting yourself in the place of child with an imaginary friend.