That my friend, takes years of practice, and a whole lot of shooting.
I grew up in a sporting goods store, and I started shooting at a very young age. I learned fairly quickly that every gun needs a bit different hold too achieve the best accuracy. For example, I once owned an H&R in .22 Hornet that just didn't care how it was held, with 1 inch 100 yard groups being the norm. A really old 257 Roberts I bought used wouldn't shoot over bags, but did well off hand. If I knew why, I'd be rich!
In the intervening 70 or so years, my ability to shoot offhand has diminished quite a bit, but I'd like to think am still rather good when using bags. Yet the differences are still there. Using my W.A.R. Cobra, shooting 25.4 grain AirArms at 875 fps, I can hold 3/4 inch groups at 70 yards over bean bags. But if I use the bipod and a rear bean bag at that distance, the groups open up by about 50%.
One thing I do know. Far too many folks buy a gun (air or powder) because they heard or think it is a tack hole shooter. Once they get it, they're disappointed because it won't hold a group. If the truth be known (save for almost any nitro-piston gun), it is the shooter's fault, not the gun's. And let's not forget, some guns like a specific pellet if accuracy is the goal.