In the most general way, let's say that you assume you are an above average player (if you didn't, the most profitable thing to do is to not play poker!), and that whenever you voluntarily enter a hand you do so because you expect to make a profit from doing so (or else you would have folded!). Once you make a determination that playing a hand is profitable, then you should want the final pot to be as large as possible and a pre-flop raise amplifies the size of the pot on each successive street compared to a limp.
For example, if you limp in and everybody else folds, and then there is a pot sized bet and call on every street, the final pot will be 2.5*3*3*3 = 67.5 big blinds [the pot triples on each street because we have (starting pot) + (pot-size bet) + (call)]. If instead you had raised even the minimum to 2 big blinds, we end up with 4.5*3*3*3 = 121.5 big blinds. A larger raise amplifies that even more of course, but the point is that any addition to the pot early on causes the pot to expand in an exponential-ish way. With the assumption that you're playing a hand because you expect to profit for it, this is a good thing.
Limping can lead to big pots too because more players are likely to then enter to pot, but the tradeoff is that your chances of actually winning the hand go down. Another benefit to raising is that it help define your opponent's ranges which can help your decision-making on future streets. Also, don't forget that by raising, you can win the hand right there with no risk! Lastly, many if not most flops simply miss most pre-flop hands; being the pre-flop raiser gives you the impetus (or "benefit of the doubt") as to having the better hand, so that opponents may check to you (giving you more options than having to face a bet) or they'll give more credence to your bluffs (you can chase away a low pocket pair or even a hand that dominates yours when you have two face cards). You can win more pots and they'll also be larger than if you had limped preflop.
So what's the case for a good time to limp then? Since, as I mentioned above, you're only playing hands if you deem them to be profitable, the time to limp would be specifically when by limping you increase the amount you expect to profit on average. That means either increasing your chance of winning or increasing the size of the pot or some combination of that. Limping will never lead to fewer players, so you can rule out that your chances of actually winning the hand will ever go up, which leads to the option of increasing the size of the pot when you win. You could come up with some random scenarios where that may be possible, usually given specific table conditions. I mean, maybe it's possible that you're at a table full of fish who are very loose preflop and who regularly build up very large pots after the flop with weak holdings. Then you could limp in for cheap flops and still be assured at taking a large pot when you hit the board strongly (limping > raising because it's a reduced initial cost to speculate, but the same payoff). But it's rare to find such conditions that warrant limping.