We commonly see this in herd animal, especially where one species is relatively rare within a given region. So long as they don't irritate the other species too much, it may be to the benefit of the rarer one to join the herd of the more common species, gaining the advantage from large herd sizes that it cannot achieve on its own. Aside from grazing herd animals, other social animals that often congregate with other, related, species, include examples among both primates and cetaceans. (Examples from other groups of mammal are rarer, but have been reported).
Broadly speaking, there are three different reasons why animals might want to actively hang out with members of another species. There is no particular why two or more of these reasons cannot be true at once, and disentangling them can take a fair amount of observation. Let's take a look at one recent study as an example.
Conducted by Jeremy Kiszka of the University of La Rochelle, and colleagues, this looked at two species of dolphin living off the coast of Mayotte, an island lying between Madagascar and Africa. The spinner dolphin (Stenella longirostris) and the pantropical spotted dolphin (Stenella attenuata) are somewhat similar in appearance, although the latter is noticeably larger, and they both live in warm waters across all three of the Atlantic, Pacific, and Indian Oceans. Both are also athletic and playful animals - the spinner dolphin, for instance, is not named after somebody Spinner, but because it likes to spin through the air as it leaps in and out of the water.
Dolphin Dolphin Common
| | Bottlenose
| | Dolphin Clymene
------------- | Dolphin, etc.
| | ^
| | | Common
----------------- | Dolphins
| | ^
| | |
------------------- | Spotted
| | Dolphin
| | |
As the above shows, despite the similarity in names, the two species do not seem to be that closely related. As I mentioned before, when discussing the newly "discovered" Burrunan dolphin, there is some degree of confusion as to how all these types of dolphin are related to each other, and the scientific names they are presently stuck with are not particularly useful. The spinner, spotted, and Clymene dolphins were all assumed to be related, on the not unreasonable grounds that they look much the same as one another, but it turns out that they are just as close to the bottlenose and common dolphins, which look quite different. This confusion has yet to be properly sorted out.
Over the years of their study, the researchers found that about one in five groups of dolphins actually contained at least one member of a different species, which is a relatively high proportion, in comparison with that found in other studies. In many respects, the associations seemed to be fairly random, although the mixed-species groups were larger than those with only one species, which suggests that just being able to get larger numbers together may be part of the animals' motivation. As with most dolphins, neither species is exactly numerous, with local populations of only a few hundred or so.
So, how do they benefit from these larger, mixed-species groups? The first of the three likely reasons is access to food. That is, either larger groups are better at finding food, or they are better at catching it (or both). This type of benefit has been observed, for example, in monkeys. However, it's pretty difficult to spot with dolphins, because they hunt their food underwater, where you can't see them.
Nonetheless, it does seem unlikely, for a couple of reasons. For one, the groups were spotted during the day, but both types of dolphin hunt at night, so they must have at least some other reason to stay together outside hunting hours. They also don't seem to hunt in the same way, which would make it difficult for them to cooperate. Specifically, spinner dolphins feed at greater depths - down to 400 metres - than spotted dolphins do, and may be eating different sorts of fish as a result.
A more likely explanation, perhaps, is protection from predators. Indeed, in general, this has been found to be the most common reason why different species congregate together. Diana monkeys and red colobus monkeys, for example, band together to ward off marauding chimps, while Thomson's and Grant's gazelles group up to protect against cheetahs. In the case of the two dolphin species, the main predators are likely to be sharks, although there are killer whales in the neighbourhood too.
The advantages of ganging up to form larger groups are two-fold when it comes to predators. The sheer size of the group may deter predators from attacking, and it's easier for members of the group to spot anything that's coming. Simply put, there is safety in numbers.
The researchers suggest a number of reasons why this is likely to be the main reason for the aggregations in this particular case. When they were spotted in mixed-species groups, the dolphins were usually travelling, rather than feeding or socialising and, in particular, the spinner dolphins were happier to travel out into deeper water when accompanied by spotted dolphins than they would be otherwise. That makes sense, because they're the smaller species, and potentially the more vulnerable to attack. Having larger dolphins around to help protect you may make you more willing to travel long distances.
There's also the factor that, while both species tend to hunt at night, the spinner dolphins are the more nocturnal of the two. Perhaps they are tired during the day, and less able to keep a look out for predators; if the spotted dolphins are more alert, that would clearly be a help for their sleepier cousins.
Finally, animals associating with another species might gain some sort of social advantage. For example, they might be able to defend a larger territory, thus gaining access to more food, without having to share with other animals that eat the same things as they do. This has been demonstrated, for example, with guenon monkeys. Or it could be something more nebulous, allowing social animals to hone their skills in the absence of many other members of their own species. Indeed, this has been shown with spotted dolphins before, albeit in this case, in groupings with bottlenose dolphins, where they have been observed to go as far as to engage in sexual activity and to look after sick bottlenose young.
In this particular case, there is no real evidence of that, but there isn't much evidence against the idea, either - especially if, for example, they were doing much of their interacting underwater where they weren't visible. Since there's no reason they can't do that and still help protect each from predators, it remains a possibility that there's something else going on that we can't see.
Sometimes, its not enough to understand how individuals interact with their own species. The world can be a little more complicated than that.
[Image from Wikimedia Commons. Cladogram adapted from Charlton-Robb, et al. 2011]