Apple says: "Some purchases might require that you have a credit card on file, even if you use your Apple ID balance to make the purchase." - from: What you can buy with your Apple ID balance --> https://support.apple.com/HT211187
For a variety of reasons Apple will almost always require a functional payment method such as a credit or debit card be present when downloading anything from the iTunes or App Stores that isn't totally free (so, for example, a "free trial" that turns into a paid subscription isn't ' free'), even if the item will be paid for with Apple Account balance. The only solution to satisfy this requirement is to add a valid payment method*.
This document explains how to 'Change, add, [review,] or remove Apple ID payment methods' on a Mac or Apple mobile devices; click here --> https://support.apple.com/HT201266
Once you have resolved having a payment method present:
How App Store and iTunes Store purchases are billed. Click here --> https://support.apple.com/HT201359
"Which payment method is charged?
When you buy items or pay for subscriptions, Apple automatically attempts to charge your payment methods in this order:
1. Apple attempts to use your Apple ID balance to cover the full amount.
2. If you don't have Apple ID balance, you don't have enough to cover the full amount, or an item cannot be paid for with Apple ID balance, Apple attempts to charge your primary payment method (typically a credit or debit card, but varies according to country). The primary payment method is at the top of the list in Settings on your iPhone. You can control which payment method is at the top of the list.
3. If there's a problem with the primary payment method, or if the primary payment method can't be charged for the full remaining amount, Apple attempts to charge your other payment methods in order from top to bottom. If none of them can be charged, Apple may try again.
Some purchases aren’t charged to your Apple ID balance
- If you're in a Family Sharing group, purchases are charged to your personal Apple ID balance. If you don't have enough Apple ID balance to pay for the purchase, the remainder is charged to the family organizer's primary payment method.
- You can’t charge gifts to your Apple ID balance. If you send a gift or gift card, your primary payment method is charged.
- Some subscriptions might not be charged to your Apple ID balance.