Not sure what your question is. It looks like you already know what to do about it, i.e. move all your mail stored in the account’s mailboxes to custom “On My Mac” mailboxes. Messages stored there won’t be lost as a result of deleting the account. What gets deleted are the account’s mailboxes and, consequently, the messages stored in those mailboxes, but not the messages stored elsewhere.
Whatever you do, however, quit Mail and make a backup copy of the
~/Library/Mail folder first, just in case. You can do this in the Finder by dragging the folder to the Desktop while holding the
Option (Alt) key down, for example. This is where all your mail is stored.
Note: For those not familiarized with the ~/ notation, it refers to the user’s home folder, i.e. ~/Library is the Library folder within the user’s home folder.