It's not the best investment in history: there are people who have won more than $100,000,000 on a single $1 lottery ticket.
Plausibly, the decision to invest in Facebook (and similar opportunities when they present themselves) had a positive expected return at the time. Even knowing Facebook is an outlier result -- like a winning lottery ticket -- its payoff actually gives us a hint that the original decision was positive-expectation, and its magnitude. (The fact that a lottery ticket happens to win changes our idea of the original expectation not at all.)
Also of note: Thiel didn't just invest money, he invested his expertise and network. That, which almost certainly helped Zuckerberg aim higher and avoid pitfalls/compromises that took down other companies, was one of the best non-monetary investments ever.