China keeps trying because an oil passage through Pakistan from middle east saves China alot of money and prevents a risk from oil tanker getting attacked in the pacific and south china sea. Moreover, a strong Pakistan is a threat to India, which keeps India pre-occupied and saves China the resources and headache in its southern border and allows china to focus on more important zones of military use such as Taiwan strait and south china sea.China really needs to start reassessing it's strategy here. Money isn't given for free.
Pakistan is a counter to India but if the money is going into a blackhole, maybe China should put it somewhere else. There isn't enough urgency from Pakistan here.
This is why China keeps committing on Pakistan even though from the looks of it. It's a completely one sided relationship in favour of Pakistan.
The main reason is India. Nothing more.
