Caste System in Vedas
Why do Vedas, which are authorless and eternal
They are not authorless and eternal. The Vedas are authored by the rishis based on their spiritual experiences. This is said by the rishis themselves in the Vedas. For example:
RV 1.61.4: asmā idu stomaṃ saṃ hinomi rathaṃ na taṣṭeva — “For him, I design this hymn, just as a carpenter designs a chariot”
RV 1.94.1: imaṃ stomamarhate jātavedase rathamiva saṃ mahemā manīṣayā — “This stotra we make for the most sacred Jātaveda with deep meditation, just like building a chariot”
Rig Veda Book 4 Hymn 26 and in Brihad-aranyaka Upanishad (1.4.10): Seeing this, the sage Vamadeva repeated at every moment: "I was Manu. I was the sun-god."
contains something like caste system which divides people on the basis of birth and even if they divide people on the basis of guna or karma why there is restriction on them for reading the vedas, performing sacred rituals etc.
Because based on past merits and sins, they have the right to perform some duties whereas some do not have that right:
Chandogya Upanishad V.10.7 - Those whose conduct here has been good will quickly attain a good birth (literally womb), the birth of a brahmin, the birth of a Ksatriya or the birth of a Vaisya. But those whose conduct here has been evil, will quickly attain an evil birth, the birth of a dog, the birth of a hog or the birth of a chandala.
A person who kills a holy man (Brahmin), or steals his property and gold, will be born as a Chandala in a future life. His punishment will be that he is obligated to work in the graveyard, which is the duty of chandalas. Contrarily, someone who does good deeds will be born as a Brahmana, who is required to teach the Vedas.
So based on past merit and sins, one is rewarded pure and impure work. This is just like how in the modern jail system, criminals have to do community service work by picking up trash.
whose goal was to tell the humans to realize the truth and become free(attain moksha) should be open to all humans?
As a matter of fact, moksha is open to all castes, but the path to moksha is different.
Bhagavad Gita 9.32 - O son of Pṛthā, those who surrender to me, even though they are of sinful birth, women, vaishyas, or shudras, they will still attain the supreme goal (moksha).
Bhagavad Gita 18.66 - After abandoning all the other means of liberation, surrender only to me. I will release you from all sins.
So moksha is open to all.
Note: “The question: Caste System in Vedas” is licensed by Stack Exchange Inc (https://hinduism.stackexchange.com/); user contributions licensed under CC BY-SA.