Betting these hands is great because : 1) people with similar hands will fold, rather than making you fold. For example, if you have 99 on a T54 board, and your opponent has 88. Either one of you might bet the flop and the other might call. Now whichever one bets the turn probably wins the pot. You have effectively the same hand, but the more aggressive wins a decent size pot. Most people even fold a hand like TJ to a turn bet there. Over time all those pots you win when you have effectively the same hand add up since you will often both have marginal hands.
2) people with awful hands will call. For example people will call with A5, 67 (draw), even gutshots, underpairs like 22. They call and you figure you must be losing but you get to showdown and are shocked to be ahead.
The weird thing here is that 1 & 2 are totally contradictorary. It's profitable because people fold similar or better hands, it's also profitable because people call down with garbage and pay you off.
* betting has positive selection bias * raising preflop selects for loose players; when loose = bad, that's good * if a coin flips heads N times it's more likely the one biased towards heads