For schools that offer merit scholarships, it's generally the most "qualified" or "desirable" applicants. What constitutes "qualified" and "desirable" will vary to some extent from school to school. Do some perusing on SDN to get an idea of which schools are particularly friendly with merit scholarships. In general, though, high numbers, strong ECs, and something about you specifically that makes a school want you will all contribute to your chances of getting a merit scholarship.
Need-based are obviously just that.