How Apple uses your trusted phone number
Apple accounts use two-factor authentication. When you sign in on a new device or on iCloud.com, Apple usually shows a verification code on a device you are already signed in to. If none is to hand, you can ask for the code by text or phone call to a trusted phone number instead.
The trusted number is also part of account recovery. If you forget your password and have no trusted device, Apple can use the trusted number to help you get back in, sometimes after a waiting period meant to protect the account.
An Apple ID verification code by SMS is a short text from Apple with a six-digit code. Apple will not need you to read that code out to someone who calls or messages you, so never share it.
Apple ID verification code not arriving
Check which trusted number Apple is using. The prompt shows its last digits. If you have changed numbers since setting up the account, the code is going to the old one: choose another trusted number if you added one, or start account recovery.
Try the phone call option if texts are not getting through, and make sure the country code is right. Repeated requests can be slowed down, so wait a few minutes before asking again.
When you create an account or add a number, Apple may refuse some numbers, including some VoIP numbers and numbers already used with other accounts. If that happens, try a different type of number rather than retrying the same one.
Why your iCloud trusted number must be one you keep
Whoever can read texts to your trusted number can receive your verification codes. If it is a free shared number, anyone browsing its public inbox can see them. Combined with a leaked password, that is a direct path into your iCloud.
A per-code number is private but temporary. Once the order ends, you cannot read new texts to it. If Apple later sends a code there, or you need it for recovery, you are stuck.
Apple's own advice is to keep your trusted numbers up to date. Treat the number on your Apple ID as a long-term key, not a sign-up formality.
Using a rental as a trusted number for iCloud
A private rental is a dedicated non-VoIP number with an inbox only you can read and unlimited SMS, from $4.99. Periods run from 1 day up to 12 months depending on the country. For Apple, pick a long period and renew it before it ends.
Add it in your Apple ID settings under sign-in and security, read the code on the rental's page, and keep a second trusted number you own as a backup. If Apple refuses the number, cancel between 5 and 120 minutes after renting, before any SMS arrives, for a refund.
If you ever stop renting, add a replacement and remove the rental from your trusted numbers first.
iCloud without a phone number: what is possible
People searching for iCloud without a phone number usually want to avoid giving Apple their personal number. For current accounts, Apple generally requires at least one trusted phone number for two-factor authentication, so some number is needed.
What you can choose is which number. A rental you keep meets the requirement without using your personal SIM. Apple also offers a recovery contact and a recovery key in its settings, which give you more ways back in. Read Apple's notes on the recovery key first, because it changes how recovery works.
A virtual number for Apple ID on a per-code basis, from $0.50 on the /otp page, fits only a one-time check, such as testing, where the number will not stay trusted. Start with VoIP High Quality (US, +1), the cheapest pool, and move to a rental if Apple refuses it.