I want to prefill a text input field on node red start. When I modify the text input field, the value is already stored as global variable which is saved to the filesystem.
Now I want that when I restart the mosquitto broker or node red, that node red restores the global variable to the specified text input field.
You can configure an Inject node to fire on startup, feed that into a change node which sets msg.payload to the global value, and feed that into the text node.
What has mosquitto got to do with this question? If the value is coming from MQTT then feed that straight into the text node.
Retained messages are kept over a restart or power cycle and the last values automatically injected on connection, so either a reboot, mosquitto restart or node-red restart will all result in the latest value being received. Much more convenient than using context. This tutorial is excellent and will explain in more detail if you need it. MQTT Essentials - All Core Concepts Explained
Just to clarify, with mosquitto, whether to save retained messages over a restart or power down is actually configurable via the mosquitto config file. The default for Pi OS, and Ubuntu (and Debian I assume) is, in /etc/mosquitto/mosquitto.conf