"Please give us five glasses."
Here it functions as the object "glass", not as a measure word (here you are "measuring" glasses). You wouldn't need it in, e.g., 五杯水 (here you are "measuring" water)
I think, and I might be wrong here, that 杯子 is the object, while 五杯 would be a measure.
As a measure word, 杯 is use for what goes in the cup/ glass (the drink), not for the container itself. You wouldn't say "5 glasses of glasses", but you could say "5 boxes of glasses". Even though boxes isn't the same as 个, I think you can see the similarity. And as others have said here 杯 is part of the word 杯子 - the object being "measured".