I think perhaps if has to do with where the animal was before being caged/penned/etc. If an animal doesn't know any other way of life than that of a domesticated nature (ie being penned in), obviously the animal would probably be happiest caged. However, take an animal straight from the wild and pop them into an enclosure and I think more often than not, you're going to have a hard time ensuring the animal remains happy and stimulated.
I think one of the main issues when it comes to caging animals is that animals need to remain mentally stimulated, need to get exercise, need company (some more than others depending on species), proper feeding, watering etc and keeping these up to a standard on par with the animal being in the wild, can in some cases, animal depending, be a challenge in itself.
Obviously you can study the animal, it's behaviours, signs of stress (eg heart rate), hormone levels etc, look at the welfare inputs (eg what is physically put there - food, water, type of enclose) and outputs (looking at the animal physically) but it really is hard to say because obviously no animal can actually right out tell us what they prefer.