Answer
$$x-1$$
Work Step by Step
Recall, one never divides by a fraction. Rather, if we want to divide by a fraction, we multiply by the reciprocal of the fraction. Recall, the reciprocal of a fraction is that fraction with the numerator and the denominator switched. Thus, we find:
$$ \frac{\left(x^4-1\right)}{x^2-x-2}\times \frac{x-2}{\left(x^2+1\right)}\\ \frac{\left(x-1\right)\left(x^2+1\right)}{x^2+1}\\ x-1$$