Historically, a chorale is a hymn sung by the congregation in a Lutheran church. From the earliest times, the music and texts were adapted from pre-Reformation hymns, from secular songs or were newly written. (Martin Luther himself was a fine composer of devotional music.)
Within 100 years the chorale was a central part of the Lutheran service – as it still is (though mostly known as a hymn) in most Protestant churches. During the 17th and into the 18th century, the chorale became formalised into the four part (SATB) harmonic style known from the chorales frequently included by J. S. Bach in his feast-day cantatas, many of which became known as “chorale cantatas”.
The chorale prelude grew out of a short introduction on the organ leading to the congregation’s singing of the chorale. As has so often happened in music, this grew into a form on its own, exemplified by Buxtehude and Bach, then later continued into the 19th century when Max Reger and Brahms wrote a number of chorale preludes with no intention at all for any choral music to follow. In England, Ralph Vaughan Williams wrote exactly the same types of pieces based on Welsh hymns, called “hymn-tune preludes” and usually heard as orchestral pieces.