How many times did somebody set you up for the perfect joke? How many times was it somebody who has no sense of humor? How many times did you have the perfect insult, perfect comeback, perfect anything to say, but you had to bite your tongue? If you happen to be me, it's a good chunk of the time.
Real life kinda sucks in that way. There's, like, consequences to your actions. In writing, there aren't. Well, there are still consequences to one's actions, but they don't affect you. That's why it is such a glorious realm of escapist fantasy. You can suddenly say everything you want, do everything you want, get it out of your system, get it out of your head, and in the least destructive manner possible.
When you use writing as escapism, you can make something entertaining, but you could also make Mary Sue drivel. They difference between the two is consequences. Even if you personally don't suffer consequences for the things that happen in your story, the characters themselves do. Good writing deals with those consequences; lousy writing avoids them.
There's a reason you don't say whatever you want in real life. You don't want to deal with the results. In writing, you still have to deal with those results, but you can do it safely. You can explore what might happen without having to experience them yourself. That is the freedom writing grants you.