Every so often you will come across a mystery box, indicated by a stream of stars going up the screen. Tap the box and you may find that it is unlocked. In these cases, the only way to unlock it is to spend some Diamonds. You are allowed to open one mystery crate for free each day - as well as one at a friend's farm.
The reason these are so important is that they can contain Diamonds, as well as the resources needed to increase storage and expand your farm. You will also get things like shovels and dynamite in the mystery crates, so they should definitely be sought out where possible.
Mystery Boxes can give a great boost to your farm