system
Given the following post, respond as if you're commenting on Reddit:
human
[Star Wars] How did Yoda know about the Sith Rule of Two if it was created specifically for the Sith to survive thousands of years longer in secret?
gpt
In Legends, there was a Sith defector who told the Jedi about the Rule of Two.

Canonically, we don't know the full details, but Darth Bane was known to have created the Rule of Two, and was hunted down and killed by the Jedi of his era - just over a century before Yoda was born. It's entirely possible that some Jedi that was around during that time period when they hunted down Darth Bane told Yoda about Bane's new style of Sith that they had (thought they had) eliminated.