Hiya!!! So I touched on a similar question about the ransom of King John II of France after the Battle of Poitiers a while back and you can read about it here. I think the difficulty with questions like this is that at the end of the day, they are counterfactual, they require us to guess about why someone didn't do something or speculate what the outcomes would be if they chose a different path. This can be extremely difficult to do and at the same time does not always yield meaningful results. Is there a specific reason you thought that Charles V would be expected/should have killed Francis I? This may help us frame our answers, but let me recap some of my points specifically for this question.
The first is the customs of war. Through much of the medieval period and beyond, there was a certain expectation that a defeated noble enemy would be captured and held for ransom. Obviously combat can be chaotic, but if the enemy is defeated and it is feasible, this would be the expectation. While the specific circumstances around Francis' capture appear to be somewhat fuzzy, if he had surrendered in any way, there would absolutely be an even higher expectation of safe conduct as well, and to violate this surrender by killing him would be akin to the war crime of perfidy.
Why was this custom followed? First off, it was extremely profitable, as ransoms awarded to the capturing soldiers could make a man very rich (or your own lord may choose to reward you as well). For a military leader, a treaty forced upon a captive could have extremely favorable terms. Finally, there is also an element of social custom here as well. As I mentioned, killing a surrendering enemy would likely be seen as perfidy, but overall, killing enemy nobility without cause (even if they didn't surrender) could engender similar treatment for you or your subordinates if you were captured by the enemy, so there is an element of self-preservation and tradition amongst nobles here. It is worth noting that while this may seem like a pre-modern system of international military law, it really was not on that level. These customs could be and were cast aside. The average soldier would be killed regardless, there was no expectation of ransom there. A city that refused to open its gates had to be besieged could expect to be sacked if they were defeated. Even the noble custom could be set aside, famous examples being Agincourt or when the French Kings flew their oriflamme banner (indicating they would give no quarter to the enemy army).
Next, to build further upon this framework, we must address the fact that Charles V was looking to achieve material gains here. He had defeated a French army very decisively, captured key leaders, and likely paralyzed the government. But at the end of the day, he had not gained territory or fundamentally established his own administration over the parts of France he was interested in (Burgundy and the low countries), and unlike in modern warfare, he really did not a have tangible path to do so. Keeping Francis alive and forcing him to negotiate allowed Charles to force concessions upon the French King that Charles would have had to spend considerable effort securing otherwise. In addition, given that monarchies like France were based government very much on the person of the monarch, this basically crippled the French court as they tried to form a make-shift administration. In addition, making war against Charles V would endanger the well-being of Francis, an important consideration for the French council.
All of this may not seem to have worked out well in retrospect, but in the moment, keeping Francis alive and forcing terms against him offered Charles V a reasonably reliable chance at making gains as the result of his military victory. It fell well within the expectations of noble custom, crippled the French government and military, and offered the possibility to gain acknowledgement of territorial changes that Charles V wanted.
I hope this helps! Like I said at the beginning, if you have a more specific context for this question or follow-ups, please let me know and I will try to address it!