Following is an excerpt from the Thunderbird knowledge base article and instructions for compacting folders. The original article is found at: http://kb.mozillazine.org/Compacting_folders
When you delete or move e-mails from a folder, Thunderbird and other e-mail programs really only "hide" them (i.e., mark them as ready for permanent deletion), and these hidden e-mails still actually remain in the folder. Even emptying the trash does not permanently delete them. These hidden e-mails remain in the folder until it is compacted. If you don't compact folders your mail folders can grow very large and the program can behave erratically, so it's a good idea to do it periodically.
Don't confuse compacting folders with compressing files. It isn't some unique feature of Thunderbird. The main difference is that most other email clients by default automatically compact the folder when a certain amount of space is wasted. Thunderbird doesn't.
To compact all folders in an account: click on the account on the left, and then click "File —> Compact Folders". Compacting an account may take a few seconds or a few minutes, depending on how much mail you have and how recently you've compacted folders. If you have trouble doing this and the process stalls, try compacting one folder at a time: click on the folder and choose "Compact This Folder".
Note: try to avoid downloading e-mail while compacting folders, as it's been reported that this can cause corruption or a "folder being processed" error. For POP3 accounts: if Offline Support is installed, first go offline ("File —> Offline—> Work Offline", or simply click on the icon that looks like a lightbulb in the bottom left corner). For IMAP accounts: you cannot compact folders unless you are online.
For IMAP accounts, Thunderbird can automatically compact the Inbox when you exit: click "Tools —> Account Settings —> [account name] Server Settings", and check "Clean up ('Expunge') Inbox on Exit." If you check "Empty Trash on Exit" it will empty and compact the Trash folder when you exit.