The 21.5 inch monitor would let you sit 2.9 feet away. You'd get the same visual experience (how much viewing angle the display fills your view) with the 40 inch by sitting 5.4 feet away.
So, the 40 in TV would grant you an additional 2.5 feet of viewing distance, if you like to sit back enough to where it feels like the 21.5 inch from about 3 feet away.
But, for gaming, some might say the IPS would have nice colors. True, but maybe you will not be paying as much attention to the colors during a game?
I'd ignore the pixel density, because that's irrelevant and interchangeable between these displays because you just sit closer or further away depending on what screen size.