The can be on topic.
For example, most (all?) Australian states have an Acts Interpretation Act, which is basically the legislature making clear their intention to the executive and judicial arms of government (and to themselves) what they mean when they write a law. The NSW Act says:
33 Regard to be had to purposes or objects of Acts and statutory rules
In the interpretation of a provision of an Act or statutory rule, a construction that would promote the purpose or object underlying the Act or statutory rule (whether or not that purpose or object is expressly stated in the Act or statutory rule or, in the case of a statutory rule, in the Act under which the rule was made) shall be preferred to a construction that would not promote that purpose or object.
34 Use of extrinsic material in the interpretation of Acts and statutory rules
(1) In the interpretation of a provision of an Act or statutory rule, if any material not forming part of the Act or statutory rule is capable of assisting in the ascertainment of the meaning of the provision, consideration may be given to that material:
and then goes on to list a bunch of non-exclusive material including relevant reports tabled in Parliament before the Act was made, treaties referred to in the Act, the Minister's reading speech etc.
Since the interpretation of the law requires that the object (or "purpose/motivation/rationale behind" it) be considered it is entirely on topic.