I doubt that changing your Apple Mail settings is going to help with your disk space problem (I've got more mail items than you do in my IMAP accounts, but my Apple Mail folder in ~/Library/Mail/ is under 1 GB), but leaving that aside, here are some ways to address the question that you have posed.
If offline access to your email isn't important to you, you can simply not have Apple Mail store your email locally. To do this, in Apple Mail, go to Preferences -> Accounts -> [your Gmail or iCloud account] -> Advanced, and select "don't keep copies of any messages" under "Keep copies of messages for offline viewing".
If offline access to your email is important to you, there are a couple of options. There are a couple of options in the aforementioned "Keep copies …" dropdown menu which might help you, such as not keeping attachments or only keeping mails which you have read.
If you'd like to redirect mail from Gmail to your uberspace.de account, that is trivial. In Gmail, open your Settings, select "Forwarding and POP/IMAP", and then select "add a forwarding email address". Gmail will send a confirmation link to the email address that you provide. After that, back on that same tab, select this email address to forward to and choose what you want Gmail to do with the forwarded email (keep it, archive it, delete it). (Gmail's full instructions for this are here, which includes links to information about how to filter email that you forward.) In Apple Mail, you would then disable downloading new mail from Gmail and enable it for this new account after you've gotten qmail set up to your needs.
If you'd like to redirect mail from iCloud to your uberspace.de account, that is also trivial. In iCloud, open the Settings (lower-left corner), and enter the email address to which you want your mail forwarded. You can choose there whether iCloud should delete the mail it forwards, and I presume that you would thus not have Apple Mail downloading your iCloud mail.