It was probably his enormous fame that stopped him coming out as much as the culture of swimming.
As a teenager (when he probably wasn't even sure of his sexuality) he was forced to repeatedly deny he was gay by intrusive interviewers. Once you've done that in public a dozen times it's pretty hard to go back on it.
Anyway, no big deal for the world but a big deal for him, so good on him.