What determines the best glide speed?
Basically, the faster you go, the more lift and drag a wing will produce. These two values are not proportional, though. When speeding up, the amount of drag produced is higher than the extra amount of lift - which is why you need additional power to maintain level at higher speeds.

When you go slower, the amount of drag will reduce more than the amount of lift produced - at least for a while. That's why going slow is better in terms of gliding distance. The amount of "drag per lift" is very low. However, slowing down beyond a certain point, the wing will rapidly start producing less lift, because airflow separates from the wing. This is what's known as a stall. The best glide speed is the speed as which the drag is as low as possible while the wing is still producing a relatively large amount of lift.

This is illustrated on a speed polar, like this one:



The black line indicates the rate of sink for a given airspeed. The optimum glide speed is the speed corresponding to the point where the red line touches the black line (Vbg).

The red line is a straight line going from (0,0) and touching the speed polar at exactly one point.

A change in aircraft mass will shift the curve along the vertical axis, which is why a heavier aircraft has a higher best glide speed than a lighter one. The intersecting point between the black and red line would shift to the right as the black line is shifted down, and vice versa.