The article explains the BGP router ID] selection hierarchy
The router identifier is used by BGP and OSPF to identify the routing device from which a packet originated. The router identifier usually is the IP address of the local routing device.
The router ID is chosen based on a specific hierarchy. The router uses the manually configured Router ID from the router-id statement under [edit routing-options] if available. Otherwise, it selects the router ID from the IP addresses assigned to its interfaces.
router-id
[edit routing-options]
For the inet address family, the router ID is chosen in the following order:
Note: For the inet6 address family, the router ID selection algorithm is similar, but link-local addresses are skipped.
Please find the below Reference document:
https://www.juniper.net/documentation/us/en/software/junos/cli-reference/topics/ref/statement/router-id-edit-routing-options.html