Some gambling games, such as craps, are simply you the gambler versus the house. These games aren't really 'gambling' so much as they are simply handing money to the casino. Games such as racetrack betting are fundamentally different, in that you're competing against other gamblers with the house merely taking a cut, so in principle it's possible to win money by out-betting your competitors.
The most fundamental principle of serious sports betting is to always bet on the underdog. Intuition indicates the exact opposite, since you want to pick the likely winner, but the goal of sports betting isn't to reliably pick the winners, it's to pick the competitors whose winning changes are underestimated by the other gamblers.
There are several reasons for this. Most obvious is the human instinct to pick the single most likely winner. Also brand name creates bias, because in the absence of analysis people are much more likely to bet on a competitor they've heard of.
A much more insidious phenomenon biases even statistical methods towards the favorite. Given a field of equal competitors, after a few competitions some of them will do better by dumb luck. It is therefore necessary to attribute at least some success among the competitors with good reconds to good luck and some of the failure among competitors with bad records to bad luck, but this is difficult to do. Even worse, frequently competitors which do poorly in previous competitions don't even compete in the later ones, so the size of the pool of competitors which the lucky few remaining are culled from, and the importance of luck in their success, is much larger than it appears.
Unfortunately betting on the longest shot every time takes a long time to win money reliably. There are so few wins that luck plays a major factor. Fortunately there is a way of betting on many long shots at once and have the chances of them winning be somewhat independant. In the case of horseracing, we know that in a given race exactly one horse must win, so if any horse loses that makes it more likely that each other horse wins.
To win more reliably, do as follows: In any given horse race, sort the horses by ascending likelihood of winning, according to the odds. Set a high water mark such that according to the odds the chances of any horse above that point winning is 1/2. Throw out all the horses above the mark, then place money on each of the horses you haven't thrown out in such a way that your payout will be the same if any of them wins. For example if one horse pays out 10:1 and another pays out 5:1 you put twice as much money on the 5:1 as on the 10:1.
Remember to place bets as late as possible, so that the odds drift as little as possible between the time when you place your bets and when the race actually runs. If everyone were to follow this strategy it would cause wild odds swings during the last few minutes, but fortunately this betting strategy is so incredibly lame that the chances of it becoming that popular are practically zero.
While I'm sure this approach does reliably much better than random betting, and its payout is relatively consistent over time, practical horseraces may keep enough of the pot for the house that the long term trend is negative. Unlike on wall street, there are very few hidden fees in sports betting, but the commisions for the house can be exorbitantly high.