There’s no simple optimal formula for playing small pocket pairs. If there were, everyone would play them the same way. One major reason is that the factors that can impact your choice of action depend on more than just the cards. As a fairly simple example, if you miss the flop, it’s much better to bet into someone who plays weak tight and thus will often fold hands like a couple of overcards or pairs below top pair, than into someone else who will call or even raise with those same hands.
These cards are worth a limp and sometimes a raise, especially if the table is weak/tight giving you fold equity or you have good position. Frankly, playing ATC on the button at a weak table can be profitable if you’re willing to bet the pot on an unraised flop, and a pocket pair is better than ATC. The odds of flopping a set or better are 7.5:1, and if you do hit the flop, there’s a good chance you’ll win better than an 8:1 return on your initial call. If the table makes a post-flop call cheap, the odds of hitting a set or better by the river are 4.2:1 (from pre-flop, not post-).
These hidden sets are some of the most profitable hands in poker, especially if opponent plays top pair or two pair strong. Yes, you’ll lose most hands with small pocket pairs, but it’s not about winning hands, it’s about winning money. Sometimes you get beat set over set, but not too often.
I’ll limp with a small pocket pair any time I can, raise in late position and call some raises in later positions if the conditions are right.