Ultimately, the claim that India influenced ancient Greece before the time of Alexander (when an Indo-Greek kingdom was established) derives from the early observation of the close similarity between Sanskrit, Greek, and Latin—known since the early modern period—which suggested to early scholars that Sanskrit, believed to be the oldest of the three, necessarily belonged to an ur-culture that yielded the other two. Today, we know that all three languages (and many more) share a common heritage from the much earlier Proto-Indo-European people. This is, for example, why similar events occur in the Mahabharata and the Iliad, or why the Greek god Zeus (Dios) shares his name with the Vedic Dyaus. Thus, common elements of mythology—and therefore the philosophical ideas that emerged from them—came from this shared heritage.
But in order to evaluate whether India contributed directly to Greece, we need to think about a specific timeline to see if it’s possible. The earliest Greek report we have of India is in the fragments of Ctesias from the fifth century BCE, but his report was not firsthand. Instead, he describes how the Persians viewed India, a secondhand source. Eusebius also says an Indian was resident at Athens in Socrates’ day, but most scholars think this is a later invention. Around 300 BCE, Megasthenes actually traveled to India, and he is the first Greek on record as having visited India, either in Greek or Indian records. Later writers like Strabo, Arrian, Diodorus, and Pliny make use of his work.
Megasthenes is important, I suppose, because he is the warrant for supposing earlier influence of Greece on India or vice versa. He claims, for example, that Heracles and Dionysus had previously explored India (Strabo 15.1.6), though this was an interpretatio graeca of the Hindu gods. Some have tried to identify this Heracles with Indra, but this is not certain. More to the point, Megasthenes wrote that the Brahmans held “several of the same doctrines which are current among the Greeks… They have also conceived many fanciful speculations, after the manner of Plato…” (Strabo 15.1.59). He also said, “All that was said about nature by the ancients is said also by those who philosophise beyond Greece: some things by the Brahmins among the Indians, and others by those called Jews in Syria” (Clement, Stromata 1.15). This, some feel, indicates that the Indians gave these doctrines to Greece, even though Megasthenes calls them “childish” and only encountered them two centuries later. While Clement of Alexandria used this to argue that Greek and Indian philosophy was ultimately derived from the Jews (and was thus Biblical), Megasthenes actually meant (as Strabo noted) only to compare the two philosophies and to point to similarities of doctrine, not to propose a common origin; and at any rate, he attributed Indian philosophy to Dionysus, which would put the Greeks first (in his view). After him, the Greeks and Romans were in more or less regular contact with India, and we need not care about what they did.
In the 1950s, George P. Conger tried to resurrect the Indian origins idea, seeking to relate Hesiod and Homer to Indian analogues (apparently hoping to minimize the inheritance of the Indo-Europeans, which he considered primeval Aryanism). He found influence from India in the doctrines of the pre-Socratic philosophers, but his examples are only fragmentary similarities between metaphysical concepts, which he admits could well have diffused westward via Persia and Babylon.
If there were a connection between Indian philosophy and early Greek philosophy, it would have had to travel along that route rather than by direct contact. The fact of the matter is that ancient cultures bordered each other, and their ideas did not stay within the limits of their cities. India traded with Mesopotamia; Mesopotamia traded with Syria and Anatolia. Both of those places traded with the Mycenaeans and the Greeks. It used to be verboten to argue that the Greeks borrowed anything from the non-Greeks, but today we recognize a vast debt Greece owed to the ancient Near East. Conger argued that “indirect” influence emanated from India, and that’s probably about right (if somewhat overstated), mediated through the ancient Near East, which we know securely was a source for Greek myth, cult, and philosophy—though the influence was never one way and probably involved the diffusion of ideas in multiple directions.