I personally question the legitimacy / usefulness of affirmative action, but the best argument in support of it which I have heard is that people bound their career prospects based on the individuals they observe to be occupying those roles in society. For example, if a person is female and all the software developers they see are male, perhaps they believe that software development is inherently a male job and not for them. This could then lead to a negative feedback loop where females are afraid to make the first step into the industry because no one has done it before them, and the industry misses out on people who could turn out to be very qualified workers. Affirmative seeks to break this loop.
It forces a company to try multiple approaches to hiring. E.g. having many criteria for what the company considers a good candidate.
For example, a tech company that requires college degrees for all candidates might want to loosen that, and figure out other signals that indicate strong candidates without a degree.
There's a strong tendency to hire what you know (e.g. people like you, and to interview how you've been interviewed).
If South Africa hadn't mandated that companies have a certain percentage of blacks in senior positions, then the economic and political power still would have been heavily lopsided towards the white minority after apartheid ended. Things aren't golden and fantastic there now, but it's still more equitable than it would have been without that affirmative action.