A shard is a colored fragment of an ancient tool that was introduced in Generation III. While they have no use on their own, several NPCs apparently have some use for them, and will trade other items or services for these objects.
Generation IV diversified the use of shards by an order of magnitude, and made them far easier to find than they were in Generation III. In addition to being found in several places on the field, shards are a commonly-found item mining underground in Sinnoh, where their appearance causes some speculation that they are related to Plates. In Pokémon Diamond and Pearl, the shards' only use is to be traded ten at a time for the weather-changing TMs on Route 212. In Pokémon Platinum, however, their use is augmented. While the TMs are no longer available by trading ten, three Move Tutors will accept groups of eight in specific colors to teach moves to a Pokémon. Their availability is also increased, with Mr. Fuego, owner of the Fuego Ironworks, trading one of each color to the player for a Star Piece and what appears to be an Ace Trainer finds one to give each day in Area 6 of the Great Marsh.
In Pokémon Black and White, they no longer have a purpose other than to be sold to the item maniac in Icirrus City for $200. In Pokémon Black 2 and White 2, Move Tutors in four different locations offer to teach a move in exchange for shards, like in Platinum. One notable difference is that instead of using multiple different types of shard for a single move, each Move Tutor has a preference for one type of shard only and will request multiple of that type of shard.
In Pokémon Sun and Moon, shards can be traded to the old man who appears in the Festival Plaza castle post-game for Bottle Caps, with 30 shards of the same color garnering one Bottle Cap. Shards can be gained through mining on Isle Aphun of Poké Pelago.
Green Shards appeared in The Relicanth Really Can, when Adam found them after they fell off the fins of a Relicanth. He mistook them for emeralds, until his wife, Evelyn, identified them as Green Shards. She stated that Green Shards were used in ancient times to make jewelry, but aren't worth as much in the present. After another treasure hunt, Adam found an entire chest filled with Green Shards.