The patella (knee cap) is exposed to incredibly high loads during sporting activities, and even activities of daily living, squatting and jogging can put loads equivalent to seven times body weight through the patella - even stair climbing puts loads of three times body weight through it. So it is hardly surprising things go wrong with this joint.
What we should really be asking is why it doesn't hurt all the time!
The answer to that is relatively simple - the patella has the thickest articular cartilage of any joint in the body. This adds load absorption and its surfaces have a dynamic contact point - as the knee flexes (bends) the point of contact is constantly changing so no single point is loaded continuously. The size of the contact point varies throughout knee flexion and this changing contact area increases with corresponding increased mechanical loading so load is spread over a larger area. Finally, one of the strongest muscles in the body - the quadriceps - is available to decrease-decelerate the peak loading forces.
So what goes wrong? Very simply, this fantastic load distribution system stops working optimally and tissues are exposed to higher loads than they can tolerate. Load distribution can fail because the limb alignment is not correct, this could be from the bottom up (foot posture and movement) or top down (pelvic and thigh alignment). In this case the tracking of the patella is affected so loads are no longer spread evenly across the surface; this creates stress on the overloaded tissues and results in pain.
Following this logic, fixing the problem then requires the cause of the altered alignment to be sorted out. This could be hip muscle strength, foot posture, quadriceps strength, local or more remote tight or shortened tissues - all this needs a systematic assessment to be carried out to find the primary causes of the mal-alignment. The answer is often not a single factor which needs changing but multiple factors, with strengthening, lengthening and learning new movement patterns and skills taking time, and on top of all this the patella also needs to learn to take the loads again. Things like taping, bracing and orthotics all help, but the help tends to be temporary. Globally their mode of operation is probably to shift load and re-distribute it slightly changing stress in the short term. Similarly, most surgical techniques change the loading on the patella which works in the short term, but the fundamental reasons why the patella became overloaded still need addressing regardless of what is done acutely to relieve the pain. This takes time and that's why pain in the patella returns because insufficient time is given to allow reloading of this joint, so it has enough “loading” education to perform.