Why should a P.I be motivated to write a strong LOR even if that means losing a undergraduate from his/her lab?
When I am evaluating a research group leader, one of the most important things I examine is where their former students work.  If their former undergraduates have moved to PhD programs at excellent universities, that makes the group leader look like an excellent mentor who teaches their students well.  This improves the group leader's reputation and helps them recruit new students.

A savvy letter writer also knows that a letter which literally says "This student has excellent achievements x, y and z." implicitly says "I am a good supervisor for helping the student achieve x, y, and z."