In my opinion, and I think others would agree, it's better to acquire a player who has been developed already and is a known commodity rather than to acquire a 5th round pick. When you get down to those rounds you've got around a 1 in 10 chance at picking a player who's going to play a couple hundred games anyway.
that kind of analysis really depends on where the team is. it's also not as simple as you say.
keep in mind you can generally acquire a "replacement player" for no assets as a free agent. a replacement player is generally a cheap competent to borderline bottom six veteran depth player.
typically a 5th rounder is only going to get you a replacement player or a mostly blown prospect. unless you are loading up for the playoffs, or are in a market where you can't sign ufas, you should not use draft picks to acquire replacement players. you need to show upside beyond a standard replacement player to justify giving up a draft pick since otherwise you can sign a replacement player and keep the draft pick .
so for a bad team, what you are actually measuring when deciding whether to keep a 5th rounder or trade is the upside above replacement player level between a 5th round pick and the mostly blown prospect you will acquire. that's a very subtle difference because the upside for either option is very small.
a major difference is that if a 5th round pick busts, nobody says anything, but if you bring on board a blown prospect and give them big team ice team and it (predictably) does not work out, then not only will they will fail very publicly and make your organization look bad, they also may not even deliver reliable replacement level service.
the other big risk is that, as with tdl trades, the draft pick you give up may turn into the unicorn you were chasing and haunt you ever after.
so this kind of gamble really only makes sense for teams with lots of room on their roster and no real expectation of making the playoffs (e.g., no need to bother with replacement players). it also requires a gm with a thick hide. the safer bet for a rebuilding team is to never trade draft picks for anything but sure things, and to cultivate your draft pick garden and wait for your odds to come in.
whether that is the right bet is harder to say. we have seen benning gamble repeatedly with nearly blown picks. he has not been able to beat the odds and has been heavily criticized for the very public failures on such gambles, which impacts his job security.