When $P(x)$ is divided by $x - 1$, the remainder is $5$. So, using the remainder theorem, $P(1) = 5$. Similarly, $P(-2) = 2$
Now, let
$$\begin{align*}
&P(x) = (x^2 + x - 2)Q(x) + R(x) \\[0.3cm]
\Longrightarrow \,\,\, &P(x) = (x - 1)(x + 2)Q(x) + R(x)
\end{align*}$$
As Chris pointed out, the remainder $R(x)$ need not be a constant.
The remainder has to be of a degree smaller then the divisor's. So we assume it's a linear polynomial.
$R(x) = ax + b$,$\,$ for some $a, \, b$.
So,
$$P(x) = (x - 1)(x + 2)Q(x) + ax + b$$
Moving ahead
$$\begin{align*}
&P(1) = 0 + a + b \\[0.3cm]
\Longrightarrow \,\,\, &5 = a + b
\end{align*}$$
Similarly, $-2a + b = 2 \,\,$ [using $P(-2)$]
So, we have two equations in $a$ and $b$. Solving them, we get $a = 1$ and $b = 4$.
Hence,
$$R(x) = x + 4$$