How to explain the etymology of the word “expiate”? I found that ex means “out, for” and piate means “pious”. But I dont see how they combine to mean “to atone for”
The "ex-" element in expiate as a prefix does not only mean "out of, from, for". It also could mean "former, previous", as in "ex-girlfriend", and "not, without", and in some cases, "completely", the last of which seems to be the case here.
Etymology online's entry for expiation indicates
via Middle French expiation or directly from Latin expiationem (nominative expiatio) "satisfaction, atonement," noun of action from past participle stem of expiare "make amends for, atone for; purge by sacrifice, make good," from ex- "completely" + piare "propitiate, appease," from pius "faithful, loyal, devout".
So it makes sense to see expiate as atone completely for (because of piety).
It should also be noted that the word has not had this sole meaning since it entered the English language in the 15th century. Shakespeare, for example, used this word to convey a somewhat different meaning:
My glass shall not persuade me I am old,
So long as youth and thou are of one date;
But when in thee time's furrows I behold,
Then look I death my days should expiate. (Sonnet 22)
Here its meaning is along the lines of "end" or "expire". What's intriguing is you could see this old meaning as employing a different meaning of "ex-": "without" or "out" (out of existence).