This article explains how to move your Apple Mail data to a new Mac or to a new clean installation of the operating system. Information covers macOS Big Sur through OS X Lion.
Transfer data from your old Mac to a new Mac using Migration Assistant | Apple Support
You have options for performing the move. The easiest and most commonly suggested method is to use Apple Migration Assistant. This method works well, but it has one drawback: Migration Assistant is an all-or-nothing process when it comes to moving data. It copies everything from one Mac to another. However, you may not be interested in transferring everything to your new Mac.
If you just want to move your email, transfer three items from your current Mac to a new one:
After you’ve transferred your files, launch Mail on your new Mac. All of your emails, accounts, and rules will work as they did before the move.