The caste-system had originally been devised to bind the Hindus into a systematic unity. The real purpose of caste was to protect the weaker sections from the ruthless competition of the strong and to vindicate the supremacy of spiritual knowledge over the power of military weapons, wealth, and organized labour.
However, later the very caste system became a social evil when it was used as a weapon by the higher castes like Brahmins and Kshatriyas to exploit the lower castes like Shudras and Dalits, thus paving way to social discrimination. This exploitation included heavy taxes, prohibition of entry into the temple premises, prohibiting the study of Vedas, etc.
Swami Vivekananda said:
Caste is a social organization and not a religious one. It was the outcome of the natural evolution of our society. It was found necessary and convenient at one time. It has served its purpose. But for it, we would long ago have become Mahomedans. It is useless now. It may be dispensed with. Hindu religion no longer requires the prop of the caste system. A Brahmin may interdine with anybody, even a Pariah. He won’t thereby lose his spirituality
The Vedas never discriminated the learners on the basis of caste.
Shukla Yajurveda says that all Hindus and non-Hindus (foreigners) have the right to study the Vedas irrespective of their castes.
yathomam vacham kalyanimavadani janebhyaha,
brahmarajanyabhyam shudrayacharyaya cha swaya charyaya cha (26–2)
Just as I am speaking these blessed words to people (without distinction), in the same way you also spread these words among all men and women – the Brahmanas, Ksatriyas, Vaisyas, Shudras and all others, whether they be our own people or aliens(foreigners).
Swami Vivekananda opposed caste system and insisted that all Hindus study the Vedas. He found that India’s downfall had not been caused by religion, contrary to the general misconception. He believed that as long as India had clung to her religious ideals, the country had spiritually flourished. But the enjoyment of power and privilege, for a long time was confined to the Brahmin priests. The lower castes at large were excluded from true knowledge of the Vedas and the source of the Hindu culture were completely forgotten.
Swami Vivekananda wanted to spread the wisdom of the Vedas to all, and thus bring about the regeneration and rejuvenation of the lost spirit of Sanatan Dharma.
Once Swami Vivekananda spoke to his brother disciples about the necessity of preaching the strength giving message of the Vedanta philosophy to one and all, and especially to the downtrodden masses. But these monks were eager for their own salvation, and protested. Swami Vivekananda said to them angrily:
All are preaching. What they do unconsciously, I will do consciously. Even if you, my brother monks, stand in my way, I will go to the pariahs and preach in the lowest slums.
He initiated many Dalits into the Gayatri mantra in Bengal and converted them into Brahmins. He was highly criticized for this act by the conservative Brahmins of his time but he continued to fight for the equality of the masses.