Does your sandbox currently have a cover? If not, I'd start there. Make a cover that fits snugly.
You can also try sprinkling cinnamon in the sand and mixing it well. Use a lot of cinnamon, and sprinkle more in the sand regularly. A lot of bugs don't like cinnamon, so this may help deter them from making a home in your sandbox.