While large storage capacities from e-mail providers make the need to manage storage less of an issue these days, there are times when people may still run into storage limits or need to clear out thousands of messages that are cluttering their inboxes. This may be especially true if one's storage plan changes to a smaller level, as is the case with Apple's basic iCloud storage plan for people who transitioned from MobileMe.
If you need to clear out e-mail messages to free up space in your inbox, you can do so manually by first clicking on the Size column in Mail to sort your messages by size (including attachments), and then progressively deleting or moving them to a local mailbox to free up space in your account.
The second approach is to archive your messages and then deleting them from your inbox, which can be done by either right-clicking the mailbox and choosing Export Mailbox, and then deleting your old messages after saving the mailbox. Alternatively you can archive your messages by selecting one or more (or click a message in the list and press Command-A to select all of them) and then control-click or right-click the selection and choose Archive from the contextual menu, which should compress them and move them to an Archive mailbox on your Mac.
The last approach is to manually archive your messages using a Mail rule that will move old messages to a local mailbox, which will remove the messages from your online account and store them locally on your Mac. This approach is similar to archiving, with the exception that it allows you to customize types of messages to archive and where to store them, instead of using a specific Archive mailbox. To do this, first create a new mailbox (call it "Old Mail," "Archive," or something similar) and ensure it is created in the On My Mac location. Then go to Mail's preferences and create a new rule (call it "Old Items" or something similar). Then change the condition to "if all of the following conditions are met" and set the conditions for your archived messages.
While you can choose any conditions that will fit your needs, one setup that might work well is to archive messages that are greater than a week or a month old. To do this, choose Every Message as one condition entry and then choose Date Received as the second condition and set it to the specific time frame (i.e., greater than 30 days old). Next select Move Message in the Actions section and choose the newly made mailbox on your Mac to move them to.
When finished, save the rule by clicking OK; you can now archive any selection of e-mail messages by running the rule on it. The one caveat to this approach is rules only run automatically on new messages; therefore, for this rule to work on existing messages, you will need to invoke it manually on a selection of messages. To do this for all messages in a mailbox, choose a mailbox and press Command-A to select all messages in it, followed by choosing Apply Rules from the Messages menu (or press Option-Command-L), and any that are older than fall in the rule's specified time frame should be moved from the current mailbox to your specified archive mailbox.