The priority inversion problem does not occur if p2 waits on the mutex as well. In that case, p1 runs until finished, then unlocks the mutex, and the scheduler can schedule p3 next.
Assume p2 is NOT waiting. Instead, it does something completely different, which takes a lot of CPU cycles. While p2 is running, p1 will get little or no CPU resources. So p1 will never (or after a long time) finish and unlock the mutex. When p2 is finally finished, and doesn't use the CPU anymore, p1 will get CPU time again, finish, and unlock the mutex. Now p3 can continue.
In that scenario, p3 had to wait until p2 was finished, even though the priority of p3 was higher than that of p2.
The priority inversion problem is not a problem when all threads are competing for the same resource. It's a problem when there are different resources involved (in my example, the mutex and CPU time), a low priority thread has blocked one resource, a high priority thread is waiting for that resource, but the low priority thread can't free its resource because a medium priority thread prevents the low prio thread from running.
What priority inheritance does is: While p3 is waiting for the mutex, p1 will "inherit" p3's priority. So p1 will get the CPU instead of p2, which means it can finish its task and release the mutex as fast as possible. Once p1 has released the mutex, it will return to its own priority, and the scheduler will allow p3 to run (because p1 is finished and p2's priority is lower than p3's).