Nobody wrote the Vedas. Vedas are authorless. They are eternal and always praise the Supreme Bhagavan. That’s why they are known as Apaurusheya (authorless). The Brihadaranyaka Upanishads themselves say:
स यथार्द्रैन्धाग्नेरभ्याहितात्पृथग्धूमा विनिश्चरन्ति,
एवं वा अरेऽस्य महतो भूतस्य निःश्वसितमेतद्यदृग्वेदो यजुर्वेदः सामवेदोऽथर्वाङ्गिरस इतिहासः पुराणं विद्या उपनिषदः श्लोकाः सूत्राण्यनुव्याख्यानानि व्याख्यानानी;
अस्यैवैतानि सर्वाणि निःश्वसितानि ॥
[Brihadaranyaka Upanishad]
Here, it clearly states that the Vedas like the Rigveda, Yajurveda, Samaveda, Atharvaveda, the Itihasas like the Ramayana and the Mahabharata, the Puranas, Upanishads, and their verses, the Brahma Sutras are all the breaths of the Paramatma, who is being referred over here as महतो भूतस्य.
So, when the Vedas are the breaths of the Bhagavan, then who can compose them? Nobody. So, Bhagavan is the only source of the Vedas. These Vedas existed eternally. At the very beginning of the cosmic creation, Lord Brahma was feeling sleepy. Hence, he went into nidra. Therefore, two demons by the name Madhu and Kaitabha, stole the Vedas from Lord Brahma.
Lord Brahma, then prayed to Lord Narayana, and He assumed the form of Lord Hayagriva and destroyed these two demons, and returned back the Vedas to Lord Brahma. Lord Hayagriva composed the Moola Ramayana. This is told in the Matsya Purana. This Moola Ramayana contains 100 crore shlokas. From Lord Hayagriva, it went to Brahma, from Brahma it went to Naarada Maharshi and from Naarada Maharshi it came to Sage Valmiki. But then after that too, the Vedas were not understood.
So here, Lord Hayagriva, also compiled the Vedas into a structured format so that it becomes understandable. So, that’s why, Lord Vishnu, in Dvapara Yuga, incarnated as Vedavyasa and divided the Vedas (He didn’t compose them) into Rig, Yajus, Sama and Atharva. These Vedas never contradict themselves. But there were some parts in the Vedas, which were appearing as if they were contradicting, if we would see that superficially. Therefore, in order to clear those contradictions, which appeared to happen there, Lord Vedavyasa, composed the Brahma Sutras, which have short formula like verses which would clear the correct meaning of that part of the Vedas.
Plus, Lord Vedavyasa compiled all the 18 Mahapuranas, and wrote the Mahabharata. SriMadhvacharya says that the Mahabharata was written first and then it happened. Therefore, whenever the story of the Mahabharata was on the verge to stop, Lord Vedavyasa would come there and take the story forward, and we can notice this in the Mahabharata. And this Mahabharata is also considered as the Panchama Veda, and hence should be seen not only as a political fight, but with a vision of spiritual lessons that we can gain from it.
The Vedas and Upanishads praise the Supreme Bhagavan. But the most astonishing fact is, the Supreme Bhagavan is even beyond the Vedas. Each and every Shaastra, talks about the greatness of Bhagavan, plus the ways in which we can please Bhagavan. So, the Vedas aren’t written by anyone. Talking about when it was written? Then well, as I said these Vedas are the very breath of Bhagavan, and Bhagavan is eternal, these Vedas don’t have a fixed day, date, and time, when it was written.
Hope this helps!
Jay SriRam!
ShriKrishnarpanamastu!