Trigger template sensors persist across restarts. Normal (non-trigger) template sensors do not. From here:
The state, including attributes, of trigger-based sensors and binary sensors is restored when Home Assistant is restarted. The state of other trigger-based template entities is not restored.