A story of prejudice, ideology and miscalculation, and the dangerous consequences of algorithmic bias.