Walnut has the right combination of toughness, density, hardness, flexibility, fine grain, and availability (from commercial walnut orchards). So yes, hardness and toughness matter, but availability is important for any industrial production raw material. Walnut has been used for applications requiring similar qualities for centuries (furniture, doors, columns, etc). Various fruit woods have also been used satisfactorily for gun stocks (apple, almond, pecan, cherry, mulberry, etc), but usually do not grow to the size that a walnut tree will grow, limiting their suitability for gun stocks. Maple is good for gun stocks, a bit heavy, very hard and tough, but only available from wild stocks (not usually commercially cultivated, since it has no nut), as have beech, birch, hickory, acacia, mesquite, purpleheart, rosewood, and various furniture hardwoods (poplar, bass wood, tulipwood), usually in smaller caliber or cheaper guns. Whatever wood is chosen it must resist warping, impact/concussion caused when discharging a firearm without splitting, and be easily workable (sanding/shaping/checkering).
Since the OP mentioned Claro, I will mention that although I love the look of Claro it is nowhere near as strong as American walnut or Black walnut wood, limiting its suitability to softer recoiling rifles.