Why base32, of all things
TOTP secrets are printed in base32 for one reason: humans have to type them. RFC 4648's base32 alphabet is uppercase letters and the digits 2 through 7 — it deliberately omits 0, 1, 8 and 9 precisely because they are the digits people confuse with O, I and B. It is less dense than base64, which nobody cares about, and it survives being read off a screen and typed into a phone, which everybody does. The QR code you usually scan is simply this same string wrapped in the otpauth:// URI printed above.
How long should it be?
20 bytes (160 bits, 32 base32 characters) is the default. RFC 4226 §4 requires at least 128 bits and recommends 160 bits. Use a length and hash algorithm supported by your authenticator and verification library.
What this secret does and does not protect
TOTP is a shared secret: the server holds the same value your authenticator app does. That is its structural weakness — a server breach exposes every user's second factor, and it is why TOTP does not stop a convincing phishing page, which simply asks you for the current code and replays it within its 30-second window. TOTP is a large improvement over a password alone and a poor substitute for a passkey or a hardware key, which are bound to the origin and cannot be relayed. Generate the secret once, let the user scan it, store it encrypted, and issue recovery codes — because a lost phone is far more common than an attacker.