At a basic level:
The universe, in the beginning was very hot. So hot in fact that there were no atoms, only electrons and protons and neutrons and photons flying around. The photons were scatting off of the electrons and protons, as they interacted strongly because the electrons and protons are charged. The universe was much like the plasma you find in plasma balls, but turned up to 11. It was opaque. You could not see through it.
As the universe expanded, it cooled and at around 380,000 years after the big bang, it was cold enough that stable atoms could form. At this point, all of the photons that were flying around suddenly stopped reacting with all of the free electrons and protons, since they started to form atoms that had no net charge, behaving much like a very dilute gas, like the air. The universe became transparent. Just as we can see through air, at this point the photons could travel unimpeded. This is referred to as the "surface of last scattering", but you shouldn't think of it as a surface, you should think of it as a moment in time where the universe went from being opaque to light to being mostly transparent to light.
Having suddenly nothing to interact with, those photons just starting travelling in straight lines. Some of those photons were just the right distance from us and were pointed in just the right direction that they are hitting us just now. In fact, they are hitting us continuously since the entire universe was filled with this photons just before the universe went "transparent".
So, the CMB isn't at the edges, its everywhere, its all of the photons that are still to this day flying off in every which direction. Occasionally those photons hit something, but since the universe is mostly empty space, the fraction that hit something is completely negligible. It is safe to assume they have not interacted with anything since the "surface of last scattering" nearly 14 billion years ago.
Nowadays, those photons are long in wavelength, nearly 1 mm, because as the universe has continued to expand, they continue to cool and stretch in wavelength.