Well, it’s not a Pokémon-specific phenomenon. The general video game term is “vendor trash” – items that serve as a way of giving extra money to the player without having actual physical coins etc. lying around in places that make no sense. In a lot of games these are things like the pelts of animals, or magical body parts of rare magical creatures. Obviously that’s no good for Pokémon, so instead we get nuggets. From an in-universe perspective, well, clearly these items are useless to us, but not necessarily to everyone. Nuggets are made of gold; pearls can likewise be used for jewellery. The mushrooms, we know from a chef who will buy them in Black and White, can be used in gourmet cooking. Rare bones, and the assortment of artefacts from the undersea Undella Ruins, all have tremendous scientific value. God only knows what comet shards can be used for.