OMG, the reasons India has a caste system are myriad and are to do with thousands of years of history. Do you really want someone to explain it to you?
It is of course an indefensible system but officially it is illegal even if that proscription is widely ignored.