Dragon Magazine 278 (December 2000)
A Dwarven Lexicon (p44)
Many non-dwarven races also use the Dwarven alphabet, even if they use
different pronunciations and meaning for the characters. The gnomes,
longtime allies of the dwarves, adopted the Dwarven script ages ago to
facilitate communication in trade and their shared war against
goblinoids. Bugbears, goblins, hobgoblins, and orcs rarely use written
words, but those that do use Dwarven runes, as they are too lazy to
develop their own and recognize the value of a widespread language.
Other than giants, all the races you ask about are described in the short passage I quoted above. This refers largely to the Forgotten Realms setting, as the previous paragraph mentions the dwarven god Moradin and how he created dwarves.
Giants
Volo's Guide to Monsters
Runes and Tale Carvings (p20)
For much of their written communication, giants use a modified version
of the runic letterforms claimed by the dwarves as their own. This
alphabet is used widely today, including by many traditional enemies
of the dwarves such as orcs, giants, and goblinoids. That giants
were first in the world and thus the creators of the script is a fact
that giants take for granted but which dwarves hotly dispute.
This passage shows that either dwarves took the script from giants, or giants took it from dwarves, but which version is true depends on who you ask. This is also Forgotten Realms lore, due to the source.
As for why one would learn it from the other, it is likely due to the fact that (according to the 4e PHB and/or MM) giants had enslaved the dwarves in the past, and so the two races interacted closely and influenced each other.