Mac storage basics · Mail, Messages and chat apps
What does Rebuild do in Apple Mail, and does it free space?
Short answer: It re-reads the selected mailbox and rebuilds its index to fix missing or garbled messages. It isn't a cleanup tool and may re-download mail.
Mailbox → Rebuild re-reads the selected mailbox from the server (or disk) and rebuilds Mail's index of it. It fixes missing or garbled messages and wrong counts.
It isn't a space-saving tool: for IMAP accounts, Mail downloads the mailbox again, which can temporarily use more space and time. Use it to fix problems, not to clean up.