- because you want or need to know the answer
- because you want or need to know what the answer is not
- because having asked the question is what matters
The first reason to ask a question is fairly obvious. You are seeking positive information - what something does, when something will, etc. For example:
"Have we fixed bug 3628 yet?"
"Yup. It'll be in the next build."
The second reason to ask a question is to eliminate possibilities. These are the types of questions you ask when positive information is unavailable or unimportant. Much like the use of negative space in art*, the thing you are seeking is defined as much by what is not as by what is. Questions with non-assertive answers come up a lot in debugging problems. For example:
"What could be slowing us down?"
"Well, we don't see any processes in disk wait, so we know it's not raw disk I/O that's causing it."
The third reason is the oddest. Sometimes you ask a question and really don't care about the answer. The point is to have asked the question. This one gets used a lot in human situations, and the point is the interaction rather than the exchange of information.
Usually, it's not important to understand why you're asking a question - you'll get an answer and use it in one of these three ways subconsiously. However, when you're getting frustrated because you just can't get an answer, it can help to remember that sometimes the answer is not the point.
* I was going to include a gratuitous picture showing negative space in art, but it didn't quite fit well, so I'll stick it down here for those who made it this far. (This is MC Escher's Three Worlds)