But I just discovered that this is not the usual interpretation.
Most linguists say it comes from Buddhist practice. One of the goals of Japanese Buddhism is to cultivate an attitude of gratitude toward the world, which is sometimes phrased as believing that all of life is miraculous. Of course, it is difficult to maintain this sense of gratitude. Other people are a particular source of difficulty, always interfering with your desire to be positive about the universe. Hence, arigato. Kaki Okamura:
Arigato means that good things in life are never obvious or a natural human right, but to be able to say thank you is actually a miracle in life. There are so many things that can come in the way of something not happening or manifesting — wrong place, wrong time, wrong person, wrong words — and consequently everything good that happens to us is a combination of many miracles. The ability to say thank you is in fact, something difficult to have.
Saying "thank you" in this spirit is the linguistic equivalent of the Japanese aesthetic concepts of wabi-sabi 侘寂, "a world view centered on the acceptance of transience and imperfection".
Image is Reiji Hiramatsu, Prayer of Japan/Cherry Blossoms (2012)