Such statements in the Vedas are offensive and should be rejected. That the Vedas have many statements that simply can't be of divine origin has been known for quite some time.
There was a time when the Vedas themselves were considered eternal in
the sense in which the divine truths contained therein were changeless
and permanent and were only revealed to man. At a subsequent time, it
appears that the utterances of the Vedic hymns with the knowledge of
its meaning was important; and it was held that the hymns themselves
must have had a divine origin. At a still later period, the meaning of
the hymns showed that many of them could not be of divine origin,
because they inculcated upon mankind performance of various unholy
acts, such as torturing animals; and we can find many ridiculous
stories in the Vedas. The correct meaning of the statement "The Vedas
are beginningless and eternal" is that the law or truth revealed by
them to man is permanent and changeless. Logic, geometry, chemistry,
etc., reveal also a law or truth which is permanent and changeless and
in that sense they are also beginningless and eternal. But no truth or
law is absent from the Vedas, and I ask any one of you to point out to
me any truth which is not treated of in them.
(The Complete Works of Swami Vivekananda, Vol.5: With the Swami Vivekananda at Madura, pp.205-206)
Such statements violate reason and it is a teaching of Hindu scripture itself that such statements in scripture do not have the status of scripture.
Even the words heard from an ignorant person, if in themselves they be
fraught with sense, come to be regarded as pious and wise. In days of
old, Usanas said unto the Daityas this truth, which should remove all
doubts, that scriptures are no scriptures if they cannot stand the
test of reason.
Mahabharata Shanti Parva Section CXLII
Yoga Vasistha II.18 says:
yuktiyuktamupādeyaṃ vacanaṃ bālakādapi | anyattṛṇamiva tyājyamapyuktaṃ
padmajanmanā || 3 ||
The remark of a child is to be accepted, if it is in accordance with
reason; but the remark of even Brahma Himself, the creator of the
world is to be rejected like a piece of straw if it does not accord
REF: Vasistha's Yoga translated by Swami Venkatesananda, p 35.
Any defense of such statements on the grounds of infallibility can also be rejected. Acharya Shankara, for example, in his Gita Bhasya 18.66 says:
The appeal to the infallibility of the Vedic injunction is
misconceived. The infallibility in question refers only to the unseen
forces or apurva, and is admissible only in regards to matters not
confined to the sphere of direct perceptions, etc ... Even a hundred
statements of sruti to the effect that fire is cold and non-luminous
won't prove valid. If it does make such a statement, its import will
have to be interpreted differently. Otherwise, validity won't attach
to it. Nothing in conflict with the means of valid cognition or with
its own statements may be imputed to sruti.
REF: Srimad Bhagavad Gita Bhasya of Sri Sankaracarya translation by Dr. A. G. Krishna Warrier, p. 629.
Sri Vachaspati Mishra, another Advaita Vedanta philosopher, says,
Na hy āgamāḥ sahasram api ghaṭam paṭayitum īṣate (Bhāmatī,
A thousand scriptures cannot make a jar into a cloth.
REF: Introductory remarks in Bhamati by Sri Vachaspati Mishra
Women and Shudras do not become untruths simply because that is written in the Vedas.
Why are such statements in the Vedas?
The accurate answer is that we don't know.