I think the answer isn't simple. Both methods have potential downsides, which can be avoided if you know what's going on and have some basic processes mastered.
If you leave it in the primary, you can get autolysis flavors if you leave it there for an extended time at higher temperatures. You can pick up other off flavors because the beer is sitting on stuff that you don't want in the final beer. More stuff, longer times, more risk of flavor pickup. Most of the time, this doesn't come into play. But it can happen if you leave your beer hanging out too long.
If you rack it to a secondary, some say you risk oxidizing the beer. I say that you should learn how to transfer beer without oxidizing it. Do you dispense from your primary fermenter? You have to transfer it to bottles or kegs somehow. How is it that you can do that without oxidizing the beer, but moving it to a secondary does oxidize the beer? It just doesn't follow. Blanket the receiving container with CO2, rack slowly into the bottom, displacing CO2 as it fills. Blast some CO2 on top. Top with airlock. No oxidation. Really.
A secondary for homebrewers is like a bright tank for pro brewers. You can condition your beer this way before packaging, and you can further treat it with other additives (dry hops, flavorings, etc.). Personally, I don't use this method unless I'm not going to package my beer for an extended time and want to avoid autolysis, or when I want to fiddle with the finished beer. I usually package my beer from the primary after it drops bright.
For most scenarios, the true answer is likely "it doesn't matter." Either would work if you do it properly, and you can spend time debating the alternatives, or you can make more beer. Find something that produces good results for you, and go with it.