Hackerrank Problem - Maximizing fraction

Problem

Came across this problem. I understand MST algorithm and also read editorial. But how fraction is maximized ? Can someone explain ?