This is only a partial answer. Actual studies on this are indeed hard to find.
First of all: the healing information waves of the herbs you bring near your astral body and other such nonsense will feature in some related answers; not here.
Grain bags or cherry pit pillows are indeed used as a heat storage and delivery device. Only for heat delivery they currently feature as "doesn't hurt, may help, increases comfort and well being" for physician guidelines for lower back pain.
For the primary effect they are intended to deliver there might be even more convincing findings behind them:
When heat over 104 degrees Fahrenheit (40 Celsius) is applied to the skin, heat receptors deeper down, where the pain is, are switched on. The heat receptors in turn block the effect of chemical messengers that cause pain to be detected by the body.
Specifically, King and his colleagues discovered that a heat receptor called TRPV1 can block P2X3 pain receptors.
The filling of these bags or pillows actually does matter for a variety of reasons.
In the past they were most popularly filled with simple grains like wheat, rice or barley. This provides a nice and even, down-weighing sensation of heat. But these are problematic because of their moisture content and inherent instability. They break down and dehusk, releasing harmful dust and particles.
If used in this way they also tend to rot and mould quickly. Also the allergenic potential of the ingredients is concerning. This is another reason for not using them to apply cold: moulding will be even quicker then. For a quick make-shift heat applicator they might still be an option, just discard them after some very few uses to make sure.
Cherry pits seem less problematic in both regards, being described as a much "drier heat" but they too can be quite a surprising fire hazard when brought to heat in a microwave.
From the manufacturer of a cherry stone pillow sold as medical equipment:
Attention: Important safety information:
- Please do observe the specified heating instructions. Prolonged heating can cause higher energy and damage the pillow (ignition hazard)!
- Please warm the pillow under supervision and ensure it is not humid!
- Let the pillow cool before the next heating!
While using the cherry stone pillow for babies / children, please also note the following:
Make sure the product is intact and sealed properly! For loose cherry stones can cause choking hazard and suffocation!
Use only under close adult supervision!
Check for the suitable temperature for your child using your elbow (max. 41°C)![…]
Special instructions: To prevent decay/ formation of mold:
- Do not wash the Cherry stone pillows.
- Store product dry! Protect from moisture!
The heat storing and distribution properties of different fillers is an obvious variable to consider. Together with a parameter that is less easy to measure: coziness.
Adding other flowers, herbs and spices is often done for the non-part of this answer from the first paragraph. But when using it for delivering heat they obviously can relase volatile substances like essential oils which can have a variety of effects. Adding lavender flowers will smell beautifully and calm you down. However, all those additives I saw added to these pillows substantially increase the mould, allergy and fire hazards. If they are known or even just suspect to be effective and wanted it's probably best to use them isolated.
So, yes: the content of the bags does matter quite a bit. Using hard and dry kernels – like cherry pits or grape seeds – seems as good as using just pure sand; and both are better than grains or colourful mixtures of sometimes dubious effect.