It isn't uncommon for iRule authors to parameterize iRules. There are multiple approaches and there is no "one fits all" approach or "best way to do it".
The data-group blocking_hostnames stores FQDNs (as keys), the iRule looks up the HTTP host header against it to determine if a HTTP response should be generated.
The HTML response is also defined in a data-group. In this case it doesn't seem likely this is re-used anywhere else nor extended as the keys are hard-coded in the iRule.
The iRule uses static:: variables to reference the data-group names. On the first look this allows re-use of the iRule by modifying the values of the static:: variables, but that's not the case. See Constants.
Rule of thumb
In general separating data (data-groups) and configuration (constants, data-groups) from the code (iRules) is a good approach. It breaks up complexity, supports automation and configuration by non-iRule-savvy Operators and allows for better re-use of code.
Use data-groups when:
(a lot) of entries are required
data-group is re-used in multiple areas
data changes often
data should be changeable via an API (independently from the code)
the data is too big for an iRule (might indicate that the data-group isn't perfectly suited either -> iFile?)