Because Claude Code is not a profitable business, it's a loss leader to get you to use the rest of their token inference business. If you were to pay for Claude Code by using the normal API, it would be at least 5x the cost, if not more.
And if inference is so profitable why is OpenAI losing 100B a year
Maybe OpenAI has a 12x markup on API credits, or Anthropic is much better at running inference, but my best guess is that Anthropic is selling at a large loss.