Where did you get this data and what methodology was used to compile the ranking. I know that the Times put out a somewhat anomalous ranking last year, which placed St Andrews surprising low (this was largely attributed to a methodological error as St Andrews is generally in the top ten). Sunday Times, which many consider to be the best methodologically and the most accurate, offer the following scores:
Teaching: St Andrews (67), Glasgow (67), Edinburgh (66)
Student Satisfaction: St Andrews (103), Glasgow (84), Edinburgh (74)
Research: St Andrews (152), Edinburgh (143), Glasgow (121)
Entry: St Andrews (219), Edinburgh (204), Glasgow (203)
It appears that in all the major areas, St Andrews comes out on top. And on the whole St Andrews vs. Glasgow thing: yes, St Andrews is in most ways a better university. I think that convient location, an attractive campus, and a comfortable environment are all things to consider when choosing a university. Based on the statistics and international reputation, though, St Andrews is in a another league to Glasgow. St Andrews draws some of the top students from throughout the world (they have the highest overseas rate in the UK), but the student body at Glasgow is largely Scottish (nothing wrong with being Scottish, but the point is that St Andrews is a very different type of university).