Maybe worth clarifying, Hindu worship of cows isn't really worship of cows. It's devotion to Krishna, who - when manifested (obv according to scripture/mythology) - taught the cowherds that devotion to their cows is devotion to him.
That makes me also wonder if there was some previous material practice of devotion to cows that the religious beliefs explain, post hoc, so I'm also interested in responses to your question.
Edit now that I'm on my laptop a bit more -
Krishna (really, Vishnu) had many manifestations (avatars, myths, etc) but quite a few are associated with cows. One good reference is the Devi Bhagavata Purana, which describes the creation of Surabhi, the "divine mother cow":
“O Devarṣi! The Devī Surabhi sprang in the Goloka. She was the first in the creation of cows; and, from Her, all the other cows have come. She is the Presiding Deity of the cows. I will now speak Her history from the very beginning. Hear. Before, She appeared in the holy Vrindāban. One day the Lord of Rādhā [OP note: this is Krishna], surrounded by the Gopīs, was going gladly with Rādhā to the Holy Vrindāvan. There he began to enjoy in a solitary place with great pleasure. He is All Will and suddenly a desire arose in His mind that He would drink milk. Then He created easily the Devī Surabhi, full of milk, with Her calf, from His own left side. The calf of Surabhi is nothing else but Her wish personified. Seeing Surabhi, Śrīdāma milked Her in a new earthen jar. The milk is more sweet than even the nectar and it prevents birth and death! The Lord of the Gopīs drank the milk. What milk dropped out of the jar, created a big tank! The tank measured one hundred Yojanas in length and in breadth and is known in Goloka by the name of Kṣīrasāgara. The Gopīkas and Rādhā play therein. At the will of Śrī Kṛṣṇa, Whose Nature is All Will, that tank become full of excellent gems and jewels. Then, from every pore of Surabhi, there appeared suddenly one lakh koṭi Kāmadhenus (cows who yields according to one’s desires). So much so that every Gopa who used to live there in Goloka had one Kāmadhenu and each house had one such. Their calves again became so many that no limit can be put to them. Thus, by degrees, the whole universe was filled with cows. This is the origin of the Cow Creation. O Nārada! Surabhi was first worshipped by Bhagavān Śrī Kṛṣṇa. Therefore She is so much honoured everywhere. On the day next the Divālī night (new moon in the month of October), Surabhi was worshipped by the command of Śrī Kṛṣṇa. This is heard from the mouth of Dharma Deva. O Child! Now hear the Dhyānam, Stotra, and the method of worship of Surabhi as mentioned in the Vedas. I will now speak on this. “Om Surabhyai namah,” is the principal six-lettered mantra of Surabhi. If anybody repeats this mantra one lakh times, he becomes Siddha in this mantra. This is like Kalpa Vrikṣa (a tree yielding all desires) to the devotees. The Dhyānam of Surabhi is mentioned in the Yajur Vedas. Success, prosperity, increase and freedom come as the result of worshipping Surabhi.
Cows then have particular religious significance to Krishna (search for "Gopala Krishna" and "Govinda Krishna" for more on this). I am not an expert on modern Hindu/Vedic philosophy, but as a layperson (and somebody somewhat brought up in this tradition, albeit in the west) most things I see explain this in two ways: cows were really, really useful animals (for use in agriculture, dairy products, etc) and the duty of a cowherd to their cow is a good metaphor for the concept of dharma and duty.
Both are referenced, e.g., in A.C. Bhaktivedanta Swami Prabhupada's "Srimad Bhagavatam Third Canto Part I"
"The cow is the most important animal for developing the human body to perfection. The body can be maintained by any kind of foodstuff, but cow's milk is particularly essential for developing the finer tissues of the human brain so that one can understand the intricacies of transcendental knowledge. A civilized man is expected to live on foodstuffs comprising fruits, vegetables, grains, sugar and milk. The bull helps in the agricultural process of producing grain, etc., and thus in one sense the bull is the father of humankind, whereas the cow is the mother, for she supplies milk to human society. A civilized man is therefore expected to give all protection to the bulls and cows."
...
"According to smrti regulation, the cow is the mother and the bull the father of the human being. The cow is the mother because just as one sucks the breast of one's mother, human society takes cow's milk. Similarly, the bull is the father of human society because the father earns for the children just as the bull tills the ground to produce food grains."
...
"Human society needs only sufficient grain and sufficient cows to solve its economic problems. All other things but these two are artificial necessities created by man to kill his valuable life at the human level and waste his time in things which are not needed. Lord Krsna, as the teacher of human society, personally showed by His acts that the mercantile community, or the vaisyas, should herd cows and bulls and thus give protection to the valuable animals.
And all of this isn't to say that the idea of devotion/worship to cows specifically doesn't predate Hinduism (if it's half based on "domesticated cows are very, very useful to agrarian society, I would expect that it does).
As u/V_Krishna says, people don't exactly worship cows, but cows are very much sacred. Similarly, cows in ancient India is a matter of some debate in how they became sacred. Certainly, in historic Vedic religion, they were not. Cows were sacrificed just like horses, pigs, and other animals. In fact, the early Indo-Aryans ate quite a lot of beef and sacrificed many cows and oxen. The veneration of cows is part of the development of modern Hinduism and parallels it.
While earlier Mandalas (literally circle or poetically cycle, the name for the "books" of the Ṛgveda) describe animal sacrifice, the last Mandala seems to advocate killing only on very rare occasions and absolutely forbids the killing of dairy producing cows, calling upon Agni to slay them. Similarly, the ideas of Ahimsa advocated by the Upaniṣads entered philosophical thought, but were unevenly applied.
This is not to say that cows were not important. Rather, wealth was sometimes measured in cows and the amount of livestock was certainly a status marker. Brahmans were often marked by large pastures and cows, and beef and dairy were highly prized parts of the Vedic diet. Not only this, but cows were a symbol of wealth among the Indo-Aryans. Veneration of the cow existed, but on a more social and economic level rather than a purely religious one. Much like the peacock later on, cows were a very important symbol of wealth and status.
It is also important to note that cows seemed to have played some important role in the Indus Valley Civilization. Cows appear on seals and on the strange boards that we associate with the IVC. Unfortunately, nearly all of what we know about the IVC is speculative and their writing system is not understood, in fact we aren't even sure it IS, in fact, writing. Some have made much of the Pashupati Seal, calling the bull-horned figure in the center "proto-Śiva" but that seems somewhat speculative to me, despite the association of Śiva with bulls early on and the possible three faced form of the figure. Nonetheless, veneration of cows and a cow god appears to have been part of the IVC and possibly the Dravidian tribes, thus entering the Indo-Aryan culture via them.
It wasn't really until the Samana religions became a strong socio-political force that Ahiṃsā became an extremely important tenet. Both Buddhism and Jainism strongly condemned the sacrifice of animals and Jainism condemned even more strongly any sort of violence against any creature. Both The Buddha and Mahāvīra strongly condemned killing of any creature, Mahāvīra went so far as to declare the killing of plants and microbes as inducing bad kamma. Buddhism considered being a butcher (literally "one who deals in flesh") to be wrong livelyhood. Jain householders were similarly forbidden from dealing in meat, but went further as Jain householders were strict lacto-vegetarians.
There is little evidence of specific veneration of cows or cattle in these Samana religions, unlike elephants. Sometimes, the Buddhists or Jains will single out cows in their suttas, but more as a status symbol or an example rather than as something holy. Nevertheless, cows during the time of the Samanas were already held in high regard, though not to the point of sanctity that they would become.
In the years following the development of the doctrines of the Samanas and the codification of Ahiṃsā, political figures become more and more conscientious of these movements. Aśoka was deeply interested and at the very least sympathetic to Buddhism (though he calls himself a Buddhist and displays a more than passing knowledge of Buddhist scripture in his edicts, some have disputed that he was a Buddhist, I rather think he was). Because of this, Aśoka banned animal sacrifice and the killing of certain animals. Notably absent from these protections are cows. However this does not mean that cows were not protected, they may fall under "four-footed creatures which are neither useful, nor edible" (unlikely), one of the titles we cannot translate (also unlikely, though less so), or just assumed or ignored, but somehow I doubt it. Likely, cows were still widely eaten by the populace, both Samana and Brahmical.
During the resurgence of Vedic based religion, there was an adoption of the most forward of Samana ideals, including Ahiṃsā. Practically what this meant is that certain things became more taboo, such as war and sacrifice. Significant, is that cows aren't really mentioned until the Gupta period. The dominant school of Vedic philosophy at this time was the Mīmāṃsā school which advocated preforming the Vedic rituals as they were. To the Mīmāṃsās, dharma was action that increased happiness and the rituals in the Vedas were sufficient to increase that happiness and prove ones own worth. The Vedic rituals, according to them, must work since they are accepted and sometime they worked. If they failed, it was not the fault of the ritual itself -after all, if so many people believed they worked for so long, and if they were written in scriptures held holy by so many they must have basis in truth- but the fault of the performer, clearly they had done something wrong. Since the Ṛgveda advocates the sacrifice of oxen and cattle, clearly it is allowed. Of course, the Mīmāṃsā would fall from prominence in the Gupta period with the rise of Vedānta (arguably the successor to Mīmāṃsā), Nyāya, and Yoga. This would of course intermingle and eventually form the foundation of most forms of modern Hinduism, especially Yoga and Vedānta.
Rather than specifically religious change, it was social change that would bring about the veneration of cattle. With Mīmāṃsā rapidly being replaced by Vedānta and the absorption of the Samana religions (especially Buddhism) into Hinduism, the importance of rituals was waning, but the real change was the increased land and pasture ownership of Brahmans. As Brahmans were no longer the sole keepers of religious texts in practice, they consolidated power through traditional means of land ownership and political clout. The Guptas were among the first to actually criminalize the killing of cows for food, and Brahmans from the late Gupta period were expected to do penance on eating cattle. This was justified on grounds of ritual purity, which would become an even more important feature of Hinduism in the coming centuries.
It should be noted, however, that both The Laws of Manu (200BCE-200Ce) and the Mahābhārata (300BCE-400CE) both advocate vegetarianism, or at the very least consider it worthy of merit. Not only this, but by the Medieval period in India, Ahiṃsā had become vitally important and vegetarianism was widespread among all traditions. Specific veneration of the cow had grown as well, though not to the point it would later grow to.
The veneration and sanctity of cows became extremely important during the period of Islamic rule from roughly the 13th to 18th century CE. Much like other shared features of the diverse traditions we now associate with Hinduism, it became a marker of pan-Indian and, more importantly, pan-Hindu identity. The shared features of Dharmic religions were a sort of rallying point for the previously somewhat disparate traditions that comprised Hinduism in the medieval and classical periods of India. Mughal emperors leveraged cattle as to appease the general Hindu populace and later the British did the same. Ritual purity and Caste were more enforced than before under Mughal (and later British) rule and this tied into how cattle were viewed by the populace. Veneration of cows became a rallying point for Hindu and Indian nationalists during the late Mughal era and the Raj.
During the Indian Independence movement, Hindus, Sikhs, and Jains used the protection of animals, specifically cows, as a rallying point of seperation between them and both the British as well as the Muslims in government. Riots would break out to protect cows, and violence would be widespread over the process of butchering Halal meat, with many considering inhumane. However, this is part of a larger social conflict between the various religious groups in India, with the Muslims being seen as foreign or invaders by the Dharmic religions.
Sources
Jha, DH The Myth of the Holy Cow (Note that this is very biased
Chapelle, Christopher Nonviolence to Animals, Earth, and Self in Asian Tradition
McEvilley, Thomas The Shape of Ancient Thought
Bhikkhu Bodhi The Numerical Discourses of the Buddha