~/Library/Containers contain the home directories of sandboxed apps.
Sandboxed apps are for example the apps you download from the Mac App Store. Sandboxing means that they are "isolated" from the rest of the system, so that a single app is not able to do unjust harm to other parts of the system.
Therefore sandboxed apps are normally not allowed to just write to any file system path they want. In order to support writing to standard paths without having to rewrite the apps, the system will create a Container folder that the sandboxed app can write into. The sandboxed app thinks it is writing into a system folder for preferences for example - but the system rewrites the path so that it ends up in the Container folder instead.
For example many apps wrote their data to
~/Library/Application Support/. A sandboxed app cannot do that - and the data is instead written beneath the
~/Library/Containers/ path for that app.