those food cat memes always make me think of a kitten wearing a costume that his mommy made him
No joke is one-size-fits-all, but adding "but I remain optimistic" at the end of any somewhat-speculating statement makes it funny, taking a different tone in each.
Adding it to the end of something positive gives it an unexpected twist - implying that whatever the good thing that happened was, it wasn't what you expected or hoped to happen, but you're yet to give up hope of whatever the fuck you've now vaguely implied towards might still happen. "He survived and is expected to make a full recovery, but I remain optimistic."
Adding it to a neutral statement implies that you think something can be done about it, funniest if the statement is something that obviously can't be affected. "Apparently it's tuesday tomorrow, but I remain optimistic."
And the bleakest, most hopeless statements just become bleakly funny by the grim absurdity. "About 30 seconds remain until impact, and the chances of any of us surviving the crash are zero. But I remain optimistic."