That’s a major thought experiment in the philosophy of 2 whole continents (at least — I’m not an expert on philosophy), and the plot of the entire Matrix trilogy of movies.
In other words, it’s been mulled over, talked about, had entire libraries written about, and been stretched to screaming point across three over-wordy films.
If you’re interested, start with Matrix 1. It’s probably enough on its own. Then, check out William James, especially on perception and psychology, then take a deep dive into the Ancient Greeks. I’m sorry I’m not terribly familiar with Asian philosophy, but I think Chuang Tzu would be a good place to start.
ETA, m’more-learned colleague, Donal Farrell, suggests looking at Descartes’ demon and Harman’s Brain in a vat, too.