The purpose of affirmative action is to correct past injustices by implementing policies that favor those previously discriminated against. The term was first coined after its inclusion in an executive order signed by United States President John F. Kennedy.
In most countries around the world, there have been clear examples of minorities being discriminated against. These situations of discrimination can be backed up by statistics from a national census, which most developed countries perform on an annual basis. If it's clear that a minority group, such as by race or sex, is being discriminated against when it comes to factors like employment, affirmative action can help correct any discrepancies.