The ones you buy are usually redworms and don't do well in a garden. They will work in a compost pile if it doesn't get too hot.
If you work enough organic matter into your soil the right kind of worms which are native to your area will show up on their own. Lord only knows where they come from sometimes. I've seen them show up in a garden when everything around it was dry desert. I can hardly turn a spadeful of soil in my garden without disturbibg at least a half dozen worms and I never added any. They just showed up.