How to save a Variable, triggered by an event

Use a trigger based template sensor:

https://www.home-assistant.io/integrations/template/#trigger-based-template-sensors

Your trigger is the relay state to: 'on'.

Your template for the state will be:

state: "{{ states('sensor.water_tank_level') | int }}"

So putting that all together:

template:
  - trigger:
      - platform: state
        entity_id: switch.water_relay
        to: 'on'
    sensor:
      - name: Water Level
        state: "{{ states('sensor.water_tank_level') | int }}"
        unit_of_measurement: ' ' # if you want a history graph

We could get fancy and convert that to % full if you want.

    sensor:
      - name: Water Level
        state: >
          {% set level = states('sensor.water_tank_level') | int %}
          {% if level == 5 %}
            100
          {% elif level == 4 %}
            75
          {% elif level == 3 %}
            50
          {% elif level == 2 %}
            25
          {% elif level == 1 %}
            0
          {% else %}
            unknown
          {% endif %}

        unit_of_measurement: '%'

Also when pasting code, please format it correctly. See point 11 here How to help us help you - or How to ask a good question