The term "rare earth metal" is a misnomer that's just stuck around. They haven't been rare for years - take this ad material from about 50 years ago at Theodore Gray's excellent Periodic Table Table site.
Didymium is a mixture of rare earth metals, which, when compounded with glass, imparts some color. Metals used to be pretty much our only way of imparting color. For quantum mechanical reasons, the enormous middle swath of the periodic table can impart some brilliant colors.
Modern organic dye technology has advanced like crazy, but metals are alive and well. Your green and brown glass have metals to thank.
Didymium glass specifically absorbs sodium D-lines' emission so glassblowers don't go blind. Like alexandrite, it is pink under incandescent and candleight and blue under fluorescent and sunlight.
A Tiger Team dinged Uncle Al for not wearing safety goggles over his prescription lenses and glassblowing clipons while turning Pyrex dispo-pipettes and Kimax disposable test tubes into vacuum polymerization ampoules (goddamned cheap employer). Uncle Al called in a favor. VP R&D was presented with a gob of didymium glass to carve into -10 diopter sphere, +2 diopter cylinder prescription glassblowing certified safety goggles.
The Tiger Team report was uncreated.
If I understand correctly the reason that rare earth metals are useful for imparting color is because unlike elements lower down on the periodic table they have a partially filled shell just under the outer shell of electrons. And all of the rare earth elements have the same number of electrons in the outer shell which makes them chemically very similar.
The partially filled inner shell however is what is interesting, the electrons in that shell can't participate in chemical bonding, they can and do however dance with photons. And with a partially filled shell to dance around in they do so happily.
The upshot is that there optical properties have little to do with there chemical properties which makes them very useful as colorants in glass and glasses and as phosphors. AKA if the element fluoresces red, then every compound fluoresces red. Which means you can tailor compounds for particular tasks without destroying the optical properties you are interested in.
Until about 1965, the red phosphor in color cathode ray tubes (CRTs) was cadmium sulfide. Not only did the "red" have an orange cast, but CdS was a much less efficient photon emitter than the phosphors used for green and blue -- the green and blue electron gun current had to be limited to keep the colors in balance, leading to a very dim picture.
This all changed with Sylvania. They introduced rare-earth phosphors, changing the red phosphor from CdS to yttrium orthovanadate, europium activated.
When I changed a picture tube in older sets, I had to bypass resistors in the blue and green gun circuits; the result was a lot of "Wow"s from the customers as the improvement in brightness and color fidelity really popped out.