Apple Mail with Gmail Account (IMAP): Moving Mails from inbox to folders fails
The following solved the issue for me:

Gmail Settings:


Inbox → Categories:
Select only Primary
Inbox → Importance markers:
No marker
Inbox → Filtered mail:
Override filters
Forwarding and POP/IMAP → IMAP Access:
When I mark a message in IMAP as deleted: Auto-Expunge off
When a message is marked as deleted and expunged from the last visible IMAP folder: Move the message to the Trash