Energy is constant in the early universe ... as it expanded, it cooled ... first we had energy condensing into matter, but things were still too hot for individual electrons and protons to associate into discreet atoms, a plasma state-of-matter, which is OPAQUE to light ... more expansion, more cooling and now Hydrogen atoms form in it's gaseous state-of-matter, which is transparent to light (most light, not all) ... any light we're receiving today (including CMB radiation) must have been emitted after Hydrogen entered it's gaseous state ... we still have all the energy from the beginning, just some of it exists as matter ... and we use the conservation of mass/energy law ...
At least that's what the egg-heads say ...
Perpetual motion is a reality? ... oh, right, it just can't be demonstrated ... perhaps if you explained in every little detail why this doesn't violate the 3rd Law, we could understand your logic better ...