The basic Kaddish text appears in fragmentary form in the Talmud (Sotah 49a, where Aramaic doxology following Torah study is described). The full text as we say it today was standardized by the Geonim of Babylonia (~7th-9th c. CE). Different versions developed for different liturgical uses: Mourner's Kaddish, Chatzi Kaddish ("half-Kaddish", shorter, for internal service transitions), Kaddish Shalem ("full Kaddish", at end of Amida sections), Kaddish d'Rabbanan ("Rabbis' Kaddish", after Torah study, including a special paragraph for scholars). All share the opening text on this page.
The custom of mourners specifically saying Kaddish is post-Talmudic, from ~10th-13th c. The story attached to it (from Tractate Kallah): Rabbi Akiva once met a man in tattered clothes carrying a heavy load. The man revealed he was a soul in torment, condemned to suffer for the wickedness he had done in life. Akiva asked: is there any way out? The man answered: only if my son were to say Kaddish in synagogue and the congregation responded "Yehei sh'mei rabba!" Akiva found the son, taught him to read, and brought him to recite Kaddish. The father appeared to Akiva in a dream and thanked him, his sentence had been lifted.
The theological logic: the merit of a mourner causing the public to bless God redounds upon the soul of the departed. By saying Kaddish for 11 months (Ashkenazi) or 12 months (Sephardi), the mourner is actively elevating the soul of the parent in the afterlife. The duration is not coincidental: the rabbis taught that the maximum stay in the post-death purification realm is 12 months, so saying Kaddish for 11 implies that the parent did not deserve the full 12, a mark of respect.
For 11-12 months, the mourner must attend synagogue 3 times a day to recite the prayer. This obligation often pulls people back into Jewish community at the moment they would otherwise drift away. Many secular Israelis and Diaspora Jews who hadn't been to synagogue in years find themselves in synagogue every day after a parent's death. Many describe the experience as profoundly stabilizing, the structure of obligation gives shape to grief.
The prayer itself is paradoxical. The mourner is sad, but the prayer is exuberantly affirmative, "Magnified and sanctified be His great name!" The act of praising God in the worst moment becomes the work of grief. By the end of the year, something has shifted.
The yahrzeit, annual anniversary of the death, continues for the rest of the mourner's life. On that one day each year, the mourner returns to synagogue and again says Kaddish. A small Jewish year-marker that runs through the calendar of every observant family.