I was thinking about putting a brief explanation of that in -- it's an excellent question. The reason is because the system isn't directly based on temperature or mass or any other obvious physical property of the stars that we often associate the sequence with. It is instead based on their spectral lines. For an astronomer, studying things by their spectral properties is the name of the game, because it is much more precise and direct from the observations. To go by temperature would be to go by a derived property, rather than by a direct measurement.
Much of this is also historical. Back before astronomers knew much about the astrophysics of stars, they started noticing that different stars had different spectral lines, but they were not simply random. There were patterns as to what lines were visible, and how strong and wide they were, that roughly corresponded to the color of the star. So different "spectral" classification systems were developed to describe these.
Some systems used numbers, others letters, and at one point there was even a system using the set A through Q (the "Draper" system). But eventually much of the letters were dropped, some of them were switched around, and today we have OBAFGKM:

Or in a graphical form:

Of course now we understand that this spectral sequence is related to the surface temperature of the stars, and it's neat to see that much of the order of the letters is maintained (A through M, except for O's and B's being hotter than A's). There is really interesting physics behind it.
Many people also ask why we don't just fix this to be A through G or something, with A's being the hottest. We could, but there is a lot of inertia with the system we use, and we just happily stick with it. It's like electricians not fixing conventional current to correspond to the movement of electrons.
