Race/ethnicity question in job applications

Hi everyone! I’ve been wondering why in the US we’re asked about our race/ethnicity on job applications. Should I be disclosing this or opting out? I’m not sure if it actually affects anything, like what real purpose does it serve?

I’ve heard technically the answers should go to the government and kept separate from your application, which is why they often ask you this on a separate section. Usually HR doesn’t look at this info and they can actually get in trouble if they evaluate your candidacy with your information about your race (although they prob all just google you). I’ve also heard some recruiters can’t even access that information?

You can opt out but it’s less a question about your candidacy, more a question of whether you want this data out there.