As you identified, there are lots of questions on here already about what number to put when an employer asks, or even whether or not you should fill that field in at all.
Your question seems different, since you seem focused on understanding why employers ask this. It's hard to answer this broadly because different employers will have different motivations for what seems like similar behaviors to a candidate. So, we can provide potential explanations but it may not play out that way at a particular employer.
You asked several related questions:
why do companies ask this instead of just including the salary range in the posting, as some places do?
Let's turn this around a bit and instead, answer: "Why do some employers actually post a salary range?"
There are a few reasons:
- They may be required to. For instance, some government jobs, or jobs where pay structures are managed via unions or some other external body, are required to state salary in job postings (or, do so indirectly by including a reference a pay grade or other standard).
- They may want to get a jump start on filtering out candidates who aren't going to work, based on fixed salary ranges. If an employer has an internal salary management policy that strictly limits salaries for open positions (i.e. "Software Developer 1" fits in a band of 73,568 to 92,334) then there's really no point in trying to hide that, is there?
The second bullet leads to your other questions:
If I put a desired salary that's much lower than they were expecting, will they underbid me?
Maybe. Shortsighted employers, i.e. those who are treating candidates as a one-dimensional resource they can attempt to buy at will for the lowest possible price, will probably do so. Other times, if your salary requirement is significantly too low, an employer may take it as a sign that you're ignorant, unskilled, or otherwise unsuitable for the job - I've watched hiring managers dismiss candidates who underbid themselves simply because, "well, if that's all they think they're worth, they must not be very good."
You also asked about the other end of the range,
If I put a desired salary that's too high, will they not consider me because of that?
Again, the answer is "maybe." If an employer has strict requirements on salary ranges, and you're way outside it, it's probably in both parties' best interests that they do not consider you for the position, isn't it?
So. All that said, to directly answer your original question of why employers ask you to state a desired salary, there are really a few possible reasons:
- It helps them understand your own perception of your value as an employee.
- It helps them understand if your self-worth fits in with what they have budgeted for the position, or what they're allowed to offer for the position.
- It gives both parties a starting place in terms of negotiating a salary to include as part of a compensation package in a potential job offer.