* Dwight's personality. Dwight is a self-righteous, know-it-all who frequently rubs his co-workers the wrong way. He is also quick to take credit for the work of others and is extremely competitive. This makes him an easy target for pranks.
* Jim's relationship with Dwight. Jim and Dwight have a complex relationship. On the one hand, they are constantly pranking each other, but on the other hand, they are also good friends. They genuinely care for each other, and Jim's pranks are often his way of showing affection for Dwight.
* The office environment. The office environment at Dunder Mifflin is generally laid-back and playful. Pranks are seen as a harmless way to relieve stress and bond with co-workers. Jim pranks Dwight as a way to escape the tedium of work and connect with his colleagues.
In conclusion, Jim pranks Dwight because of Dwight's personality, their relationship, and the office environment.