It is established fact that the Futurama theorem/proof was created specifically for the franchise, for use in the episode "The Prisoner of Benda."
(Relevant parts of the interview, emphasis my own)
"[...] a theorem based on group theory was specifically written (and proven!) by staffer/PhD mathematician Ken Keeler to explain a plot twist."
"[...] a mathematical theorem was penned for the sake of entertainment."
Despite the specific wording above, it still seems to me open to debate as to whether or not the theorem was created for the sake of the plot of that episode, or if the plot was created for the sake of the theorem.
The man himself, Ken Keeler, was not the person interviewed, it was David X. Cohen, the show’s Executive Producer and head writer. Additionally, this was not a direct quote from him, but was the (possibly cherry picked) wording of the interviewer, Alaina G. Levine.
Was the plot merely wrapped around the more-or-less already existing theorem?
Did the episode have the underlying problem, and then the theorem was created to fill that narrative hole?
Is this even publicly known?