One general purpose of the 15" ruler design is for repetitive tasks, particularly in measuring and drawing. A yard stick would be too long and a 12" ruler may be too small and tedious, whereas a 15" can be comfortably just right for many tasks.
It largely depends on the needs of the user as there are also options for rulers in 18" and 24" lengths to serve other needs.
Legal paper and A4 documents are longer than 12" and slightly shorter than 15" so these rulers were an appropriate size for these paper sizes. Drawing and measuring used to be more common than it is today and at one time, all tables and charts needed to be made by hand, which would often be made easier by a 15" ruler.
Historically, 15" rulers were also once popular for navigational use. A ruler was needed to draw a course or bearing from a given point on a printed map aboard boats and shipping vessels.
The old green bar computer paper is 14 7/8" inches wide. A plastic magnifying ruler is only used for reading lines of data. Office workers also needed a ruler with a metal edge to highlight entire lines or as a tear-off tool on a repetitive basis.
Finally, one last consideration is the ease of storage- a 15" ruler would still fit comfortably into a desk, unlike longer sizes.