This question troubled me when I viewed the relevant portion of MB.
In my view, he must have known it via his vast network of spies. We are aware of the fact that he was highly learned and possessed immense power and respect. So, post Shantanu's demise when the kingdom repeatedly faced crisis without a ruler or due to being helmed by weak and physically/morally blind rulers, he had to step in and guide the fortunes of his state. That mustn't have been possible without the aid of trusted spies.
I can't see another rational explanation that's devoid of the supernatural and the divine.