The people who first defined the terms used in programming languages were largely academics, and so probably had a more positive and familiar association with the word "library" than you seem to. I would suggest the association such folk would have with library, rather than "a big ugly building full of books" might be something like "a collection of works which allows us to gain from the knowledge and wisdom of others, and use it to progress yet further". But that's just the romantic in me...
For me it seems like an obvious analogy: a library refers as much to the collection as it does to the building itself.
For example:
Cambridge:
a collection or set of books or other things, all produced in the same style or about the same subject:
Dictionary.com:
a collection of manuscripts, publications, and other materials for reading, viewing, listening, study, or reference.
Merriam Webster:
a : place in which literary, musical, artistic, or reference materials (as books, manuscripts, recordings, or films) are kept for use but not for sale
b : a collection of such materials
For this reason the use of library in the context of a music library on an mp3 player has never scanned as odd to me either.
So what is a library in computing?
According to wikipedia, a library is a collection of configuration data, documentation, help data, message templates, pre-written code and subroutines, classes, values or type specifications. That seems like a good definition to me.
Generally the pre-written code and classes are the most important parts of that, and classes essentially boil down to pre-written code containing class definitions. What happens when I use a library in my code? The compiler/interpreter reads your code, and where you include a function from the library, it references the text of that function and executes it in your code.
Since this isn't stackoverflow, I'll use a simple pseudo-code example
-----------------------------------
##include Arithmetic_library
x = 2
y = 4
z = AVERAGE( x , y )
PRINT z
-----------------------------------
Output=3
This AVERAGE function refers to a library, which contains a function as follows:
FUNCTION AVERAGE(arguments)
total = SUM(arguments)
count = COUNT(arguments)
answer = total / count
return answer
So what does the interpreter do upon reading my code? It reads from the library. I would argue a library is a better analogy than the alternatives you provided for that reason: a library contains materials (whether books or films or audio etc.) to be referenced, and the information inside them used constructively and creatively. That is exactly what a library is in coding.
As to your proposed alternatives? A warehouse is a collection of things for storage. A factory is something that produces a limited number of well defined things (more like a subroutine if you want a coding analogy). A helper, assistant or supporter don't fit either, they imply an intelligent entity which offers you advice, a library doesn't do this, in fact it doesn't do anything, it merely is, and allows you to reference or use its materials as you please.
Another analogy that might work for instead of "library" is perhaps a "toolbox", and indeed many programming manuals informally refer to libraries as such. As to why library has taken off as the accepted term? The fact that a computing library is, at the end of the day, a large collection of useful written text rather than of physical objects, lending itself to the use of the term "library" rather nicely.