US president Joe Biden has apologised for the "unimaginable cruelty" of slavery during a gathering of African leaders at a White House dinner.