"Boiler plate" originally referred to the rolled steel used to make
water boilers. Metal printing plates of prepared text such as
advertisements or syndicated columns were distributed to small, local
newspapers, and became known as "boilerplates" by analogy. One large
supplier to newspapers of this kind of boilerplate was the Western
Newspaper Union, which supplied "ready-to-print stories [which]
contained national or international news" to papers with smaller
geographic footprints, which could include advertisements pre-printed
next to the conventional content.
The man in the foreground below is holding a rounded printing plate. This one was likely produced "custom" by the shop's typesetters, but similar plates might be provided by an outfit such as Western Newspaper Union, as described above. The similarity to literal "boilerplate" is obvious.
A "template" is entirely different -- it is intended to be modified.
1670s, templet "horizontal piece under a girder or beam," probably
from French templet "weaver's stretcher," diminutive of temple, which
meant the same thing, from Latin templum "plank, rafter," also
"consecrated place" (see temple (n.1)). The meaning "pattern or gauge
for shaping a piece of work" is first recorded 1819 in this form,
earlier temple (1680s); the form was altered mid-19c., probably
influenced by plate [Barnhart], but the pronunciation did not begin to
shift until more recently (templet is still the primary entry for the
word in Century Dictionary).
Prior to the use of the term for software, engineers were familiar with "templates" as pieces of plastic used for drawing figures. Eg, one might have one template with cutouts to draw the English alphabet, another with cutouts to draw elements of an electrical circuit. (I used both in the 70s, before I ever heard of software templates.)