A lens only focuses on one plane. For normal cameras / lenses the plane is parallel to the film/sensor, so only objects at a particular distance from the lens will be in perfect focus, though things some way in front of and behind that plane will be acceptably sharp. smaller aperture settings (bigger f numbers) increase that range, and larger aperture settings (smaller f numbers) decrease it.
So a large aperture (small f number) is handy for blurring the background and concentrating on one particular distance, while a small aperture (big f number) keeps more things sharp.
I believe you can get focus stacking software that lets you combine multiple images focused at different distances together to get a bigger sharp image range.
Unfortunately, for macro work, even with a small aperture, the depth of field (sharp range) is usually fairly small.
For a more specialised solution, lenses that can be tilted (or tilted and shifted) or a view camera (where the lens panel is mounted on an adjustable bellows setup that allows tilting and shifting) can use something called the Scheimpflug rule - this allows you to tilt the lens so that the plane of sharp focus is also tilted. Although there's still only a single plane of sharp focus, it's not longer parallel to the sensor. if you're looking down at an angle to the plants, you could set things up so the plane of sharp focus is at a particular height above the soil level. Instead of having distant plants blurred, you'd now have a particular height above soil level sharp - so maybe the tops of the plants would be sharp but the bottom blurred. A web search for "Scheimpflug" should find several explanations of how it works - basically, if you extend the plane of the film/sensor, lens, and sharp focus, the planes intersect in a line.