How to get value from {{ item.content }}
You are comparing an array with a number:

item.content &gt; 5


Try the field value instead:

element['#items'][key].value &gt; 5


Full code example:

{% for key, item in items %}
  {% if element['#items'][key].value  &gt; 5 %}
    &lt;div style="background-color:green"&gt;{{ item.content }}&lt;/div&gt;
  {% endif %}
{% endfor %}