The closest answer I can give is that it's built on the word Theke, meaning "counter", which is a feminine word. As to why that word is feminine, there usually isn't any 'reason' why words have the genders they do beyond 'that's how the language developed'. It's usually more related to the spelling of the word - if anything - than to any concept of biological gender.
I have to correct. Apotheke does not come from Theke, but both Theke and Apotheke come from either latin (which also borrowed from greek) or greek. In all of these languages they are feminine.