Brandon Sanderson's novella Perfect State is about the fantasy adventures of a brain in a jar - albeit a brain that is fully aware of the unreality of its existence, and is at heart in some existential distress because he knows his life is a game shaped by those who control the illusionary state he lives in. The main character, Kairominas of Alornia - Kai for short - infodumps the concept early in the narrative, although it's hardly necessary as Sanderson gives multiple clues to what's going on, which is this:
...the best way to create greatly satisfied people using minimal resources was to remove their brains when they were fetuses and attach them to simulated realities tailored to fit their emerging personalities. Each Liveborn received an entire world in which they were the most important person of their time. Some became artists, others politicians, but each had a chance for supreme greatness.
Kai is God-Emperor of a State based on the standard medieval fantasy tropes. He spends his time developing new ways of using the magic system active in his personal reality and engaging in battles with Liveborn from other States. He's a good God-Emperor - he cares for the simulated characters that are his subjects, and tries to make their lives happy and comfortable. Then the rhythm of his life is changed when the Wode Scroll - the representative/communications interface of the agency (whatever it may be) that manages the fantasy universes - instructs him to travel to a Communal State - one which maintains its own programming regardless of which and how many Liveborn "enter" it - and arrange to procreate with a Liveborn woman (outside the fantasy states, the two Liveborns' DNA will be merged, but for some reason, the donors are expected to simulate sex in the fantasy states before this can be done).
But Kai has a bitter enemy, one of the Liveborn with whom he has been battling sporadically for some years. And his enemy is about to deliver a most painful revenge.
The novella's congruences with films from Tron to The Matrix franchise and a wide range of cyberpunk novels and their kin is immediately obvious, although this work is different from most in that there is no way out for the Liveborn. They are nothing more than brains in jars, they must live in this artificial reality for as long as their brain tissue lives - and the details suggest that this is a very long time, at least subjectively. So the thrust of Kai's inner journey cannot be about changing the situation he is in, but rather finding ways of existing and adapting to it that will be less about playing the games set before him and more about finding whatever degree of meaningfulness he can in reaching out to the Liveborn around him to try and break the paradigm of endless struggle.
There is a moral here, I think, buried under the subjective fantasy and the vaguely suggested science-fictional world beneath it, about breaking out of the bubbles of self-delusion we create for ourselves, and the strictures of functioning day-to-day in a world that often demand of us that we conceal huge swathes of ourselves, and connecting with others on a real and honest basis. It's not a new or revolutionary idea, but it is a good one.