RE: Set Lookup Value for Child Based on Parent's Parent Relationship
There are multiple way to address it.
If you want the entity-3 lookup to entity-1 filled in real time for the user, based on the entity-2 value, then you indeed need JavaScript code.
If you don't need real time, then this can be done through workflow (but that's a legacy technology and I would advise against it) or through a Power Automate Flow.
I have a warning though: if you change the entity-1 parent from entity-2, the aforementioned mechanisms won't update the lookup value on entity-3.
So be careful about how data will live in case of reorganizations.
You could also explore additional ways to potentially achieve the functional goal (display entity-3 grand-child records on the entity-3 records): canvas app, Power Apps Component Framework, web resource, etc.