You can use Rigid Body Physics simulation.
The ground and text are set as passive objects, while the pills are active objects. Create the pills and raise them above the text then play the simulation until they settle into place, the gravity in the simulation makes them fall down while they collide and interact with each other. Once they are in place you can delete, rotate or move some of the pills until it all looks good.
Just a couple of minutes in blender I can get this -

In this example a texture is added to the items so they make up a final image, this is the tutorial on how to make that. This example has fun smashing up a building but you can see similar results at the end. Most 3D software includes or has access to physics simulations to get a similar result.