Your syntax is incorrect: you can't use {{ ... }}
inside a {% ... %}
statement.
This should work, as the inner for loop should inherit the scope of the outer for loop:
{% for ruleset in rulesets %}
<div>{{ ruleset.0 }}</div>
<ul>
{% for rule in rules %}
# = is an assignment operator (which doesn't work in templates),
# == is the equality operator, which you want to use.
# alternatively you can use {% ifequal rule.0 ruleset.0 %}{% else %}{% endifequal %}
{% if rule.0 == ruleset.0 %}
<li>{{ rule.1 }}</li>
{% else %}
<!-- Nothing -->
{% endif %}
{% endfor %}
</ul>
{% endfor %}