Why do P waves have a higher velocity in the lower mantle than in the core even though the core has a much higher density?
tldr; Increased density corresponds with decreased P-wave velocity

The P-wave velocity for an isotropic medium is:

$$
V_p = \sqrt\frac{K+4/3\mu}{\rho}
$$

where $K$ is the Bulk Modulus, $\mu$ is the shear modulus, and $\rho$ is the density (https://en.wikipedia.org/wiki/Elastic_modulus, see $M$ the P-wave modulus). Isotropy just means that the strain on the rock caused by a stress is irrespective of the stress orientation. Examining the equation you can see that increased density corresponds with decreased velocity. 

In the mantle, $\rho$ increases with depth, but the numerator $K+4/3\mu$ increases faster than the $\rho$, so the net effect is an increase in velocity. 

In the fluid outer core, $\mu = 0$. This is because fluids do not support shear stresses. Correspondingly, $V_p$ drops precipitously.

In the solid inner core, $\mu$ is nonzero hence there is a jump in velocity at the inner/outer core boundary. The combination of $K$, $\mu$, and $\rho$ in the inner core is such that $V_p$ doesn't exceed the lower mantle values.