what's the purpose of the chain_id in merge mining?
I discovered the answer in a blog:

it is necessary to make sure that a miner cannot mine on different
branches of the same child blockchain, as this conflicts with the
rules of the underlying Nakamoto consensus mechanism and would make
double spending attacks possible. Hence, each cryptocurrency must
specify a unique ID, which can be used to derive the leaf of the
Merkle tree where the respective block hash must be located.

Source: https://alexeizamyatin.medium.com/a-technical-deep-dive-into-merged-mining-5b67706e1a19