Note: all quotes in this answer are taken from this website, and according to Wikipedia they’re the Ministry of Foreign Affairs for China.
Political Influence and an UN seat.
The Taliban are likely to take over most, if not all of Afghanistan soon, and since they are recognized by most major powers, it is not possible for them to get a seat on the UN general assembly. If the Afghanistan government are friendly to China, this could give China more political influence.
Not losing people
In addition, China currently has people in Afghanistan, and the article says
The Chinese Embassy in Afghanistan is still operating normally. The Chinese Ambassador and embassy staff are fulfilling their duties.
For those few people who chose to stay, the embassy is in close contact with them.
This shows that China still has citizens in in Afghanistan, and losing those citizens would likely be detrimental, because at least some of them are likely valuable to the Chinese government.
Less attacks on China
Hua Chunying chairs in the article that
The Afghan Taliban said on multiple occasions that it hopes to grow sound relations with China and will never allow any force to use the Afghan territory to engage in acts detrimental to China. We welcome those statements.
If there are people attacking China, this deal could possibly reduce them. In addition, this means that the Taliban might not allow any forces blocking Chinese trade into Afghanistan.
Showing China is better than other countries
Russia fought in Afghanistan, and America fought in Afghanistan. Those countries are both global powers, and they both failed. If China can make diplomatic ties with Afghanistan, that could be considered a success. This would show that China is more powerful than Russia and the US, which could raise morale and political influence.