I had some bad experience with a similar situation, in my case a ESP32 (also freeRTOS based) with an ethernet arduino shield. What usually happens is that the Arduino Ethernet libraries are very old and are not well suited for a real-time OS. Sometimes the problem comes from the way the library handles Interrupts for catching incoming messages, holding the resource captive way longer than it’s acceptable for the RTOS, if not properly informed/configured.
My suggestion would be to either find a MQTT library that does not depend on the standard arduino ethernet library, and if that fails try to first find an ethernet library compatible with the STM32/RTOS, then try to adapt some MQTT library to that library.