Getting a good, in focus macro shot is not trivial. Even with a stopped down aperture, the depth of field is just too tiny, sometimes being less than half a millimeter. But usually, you want to shot open because you need every bit of light you can get, which makes it even worse.
The way to overcome this depth of field nightmare, is by shooting many photos, where each one has the focus slightly shifted, than stacking then together, and taking the focused bit from each one. You do this by mounting the camera on a slider and taking photo after photo after photo….
Or you can automate the process like pulsar124 and his Fast Stacker – a $150 solution for stacking macro shots. (Commercial version like the Stackshot only start at about $550, so if you have the time, this is quite a useful build).