It will be very long discussion and will be better if there is a dedicated thread (if it doesn't exist at present). Few basic points are following:
China is the only country which shares borders with both India and Pakistan. For China, Pakistan is strategically important for China while India is economically important. China's aim are not centered in Asia-Pacific region only.
It wants to become a world Super Power and to come at Equal standing to US. For that it needs market of India and Africa which is in hundreds of millions of people, access to Gulf through Pakistan, resources from Afghanistan and Africa without leaving it exposed as in current time all its vital sea lane goes through IOR controlled by US.
India has it s regional ambition and Global vision. Trade with China is mutually beneficial and an option to tilt towards if things with US go south, like it did in 1998.
About Pakistan, we all know how China is important for them too.
Now put all this in and see from one common frame of reference and you will start seeing the linkages of why China can successfully mediate between India and Pakistan.
If still you need more explanation, let me know.