This actually relates to the Theory of conservation of energy. In an ideal situation where there is no energy lost to the surrounding, the ball would bounce back to its original height. Why? Before the ball is released, it has only gravitational potential energy. Once it is released, this energy is converted to kinetic energy. When the ball just reach the ground, it only possesses kinetic energy as all gravitational potential energy has been converted to kinetic energy. When it bounces back up, the reverse occurs such that all kinetic energy will be converted to gravitational potential energy, thus reaching the same initial height. (E=mgh where mass,m and gravity potential,g are constant)
Therefore, the variation in loss of energy of different balls causes the difference in height which the ball bounces. Since a rubber ball underwent deformity at the area of impact and restore to its original shape after the impact, there is a more substantial energy loss in the form of heat. Therefore, not all kinetic energy is being converted to gravitational potential energy. Glass ball, on the other hand, loses less heat to the surrounding, and able to convert most of its kinetic energy to gravitational potential energy. The higher the gravitational potential energy, the higher will the ball will be able to bounce.
Note: Practiaclly, no ball can bounce to its original height because there is also the presence of air friction which also causes heat loss to the surroundings.