There are a few aspects of the medieval economy and the politics of royal succession that are worth considering to understand this.
The first aspect can be summed up in three words "a king's ransom". In a situation where there is someone willing to pay, a great deal of money can be demanded for a captured king. Richard the Lionheart was captured on the way back from the Crusades and ransomed for 150,000 marks which is equivalent to 17 million dollars just on the basis of the value of the silver. With inflation, that would be up to 3.3 billion dollars today. https://www.gainesvillecoins.com/blog/a-kings-ransom-5-outrageous-ransoms-paid-in-gold-and-silver
A dead king gets you no payout. Even lesser nobles were worth a pretty penny. The term a king's ransom was first used in print in 1525, which gives a sense of how commonly it was understood. https://www.phrases.org.uk/meanings/a-kings-ransom.html
The second aspect has more to do with understanding the political effects of a captive king in medieval politics. For this, one good example is the Wars of the Roses in England. The capture of Henry VI of England by Richard of York had a few effects. First, Richard was named as Lord Protector of England, giving him the power of a king even if not the official title. Second, Henry's supporters were not in a position to attack the Yorkist forces, because if they did, Richard's forces could kill the king. Third, Richard could exert pressure for Henry to name Richard or his son Edward(future Edward IV) as Henry's heir. Parliament passed the Act of Accord that disinherited Henry VI's son Edward(Edward of Westminster), leaving Richard of York as the de jure heir to the king. By keeping Henry VI captive, Richard could also insure that he produced no other heirs that would threaten his succession. This gave the transfer an air of political legitimacy and followed the generally accepted practices.
If Richard just killed Henry, then Henry's son Edward of Westminster would become a rallying point for Lancastrian forces because he would be King according to their opinions on succession. In the end, this didn't work out for Richard, who was killed in battle, or Edward of Westminster, who was killed in battle, but it did get Edward IV on the throne for a while. Until he married a random common woman and pissed off everybody.
M. Hicks (Ed.). The Wars of the Roses 1455–1485. Oxford: Osprey Publishing Ltd.https://books.google.com/books?vid=ISBN9781841764917