This attaches to a noun rather than an action and states a requirement about what something must be: the best singer, a distance close enough to visit often, an actual song, the last syllable of the previous word. The -여 is the copula in the shape it takes after a vowel; after a consonant you get -이어야 하다. With real verbs the same job is done by -어야 하다, and the casual spoken counterpart of both is -야 되다.