The basic rule is fish that might make a betta think it is a betta (brightly colored or territorial) is to be avoided because the betta will try and defend its territory. Also fish that are known to be fin nippers (many kinds of tetras) should be avoided as they will terrorize your betta.
Good tank mates:
Mystery snail - Found in most pet stores, this snail comes in many colors. Eats algae, left over fish food. Does not eat fish droppings. Stays relatively small and does not reproduce without a male and a female. One or two is an acceptable tank mate for a betta in a 2.5 gallon tank.
Apple snail - May be hard to find as it is an invasive species. Eats algae and leftover fish food. Does not eat fish droppings. Grows larger than the mystery snail and produces more waste so needs a minimum of 5 gallon tank. Do not keep more than one apple snail and one betta in a 5 gallon tank or there will be too much waste.
African dwarf frog - Small aquatic frog that does not produce much waste. Carnivores so do not need to worry about bettas eating frog food and frogs eating betta food. Make sure front feet are webbed when buying these frogs. Often their close relative, the African clawed frog, may be sold under the same name. African clawed frogs grow to be 5" long and eat fish. Need to keep the water very clean as they are susceptible to bacterial infections. One is an acceptable tank mate for a 2.5 gallon tank. Cannot tolerate any copper based medications or tank treatments.
Ghost shrimp - These small invertebrates will scavenge the bottom of your tank and clean up any uneaten food or algae. Need to be careful when housing with bettas though, a betta might find a smaller shrimp as an over-sized treat. They cannot tolerate any medications with copper in them.
Cherry shrimp - Same as Ghost shrimp.
Otto catfish - These algae eating catfish are a bit sensitive to things such as ammonia and nitrite spikes, so make sure to only add them to a well cycled tank. They are also sensitive to things such as temperature fluctuations and harassment from your betta. Since they prefer to live in larger groups, only add them to tanks that are at least ten gallons.
Cory catfish -A hardier scavenger than the otto catfish, these catfish still need to be kept in groups of about 6 fish which means in at least a 10 gallon tank.
White cloud minnows - White cloud minnows are very active peaceful fish. They only have a small amount of color and do not have long flowing fins that a betta can mistake as a threat. Since these are technically cold water fish, you will need to keep the tank around 76F to accommodate both the betta and the minnows. You will need at least a 10 gallon tank with many plants for hiding in this tank arrangement.
Might be okay tank mates:
Danios - These schooling fish are probably better off with plakat or female betta because they do tend to nip fins. Once again this species is a colder water fish and the temperature should be kept around 76F. Since they are schooling, you will need at least a 10 gallon setup for these fish. These are one of the hardiest freshwater fish species.
Neon Tetras - Neon tetras in most cases are very compatible with bettas as they like the same water temperature and pH, the only drawback is that they may nip your betta's fins. Make sure you observe carefully for instances of this.
Tank mates to avoid:
Other bettas - Bettas being territorial will without fail attack their own species. Some are able to keep sorority tanks of females in a well planted tank with at least 2 gallons per fish, but I do not condone this because illness and death of the dominant female will ruin the hierarchy and cause fights possibly to the death, and in milder cases resulting in missing eyes and torn fins. Some have been able to keep a male and a few females in a very large tank (over 55 gallons), but this is not recommended for a beginner.
Gouramis - Gouramis are an equally territorial fish that is prone to fin nipping. Also being that they grow to be bigger than bettas usually means death for your betta.
Goldfish - While some people might be prone to thinking that since both bettas and goldfish can be kept in bowls, they can be kept together. This is wrong on so many levels. Goldfish are not actually able to live long in small bowls because they do grow to be very large fish. The whole thing about goldfish staying the size of their tank is a myth. Goldfish also have a very high waste output which means they need at least 20 gallons of space. Goldfish also need for the water to be far from stagnant while your betta would be highly stressed in this environment. Goldfish need cooler water while bettas warmer water. Goldfish are brightly colored with flowing fins which will result in a fight. Bettas also need the completely opposite water parameters than goldfish and are not tolerant of the amount of waste a goldfish produces. This is possibly one of the worst matchings one can make.
Mollies - Mollies prefer water conditions that are too harsh for betta fins, namely a high pH, and hardness. They also tend to be somewhat aggressive which is another threat to betta fins.
Swordtails - Swordtails prefer different water conditions than bettas, come in bright colors, and the males tend to be aggressive. Swordtails also don't do well in the stagnant water necessary for bettas.
Guppies - The bright colors and flowing fins of fancy guppies makes them an instant target to male betta aggression. Female bettas will also try to interact with guppies and in most cases kill them.
Platys - Platy's pose a lot of the problems that mollies do in that they prefer water conditions that are harmful to betta fins and health, and they tend to be a bit aggressive. Platys also tend to come in bright flashy colors which will in turn make it dangerous for the platy to be housed with the betta.
Every fish is different and you might hear stories of male bettas being kept together with each other and guppies or males with females and things of this sort. These are most likely sick fish or fish that are just getting used to their surroundings. It may seem they have created a peaceful arrangement, but bettas are known to all of a sudden snap and start terrorizing tankmates they have lived with for months. For the safety of your betta and the fish you house with it, do not attempt any risky arrangements.