What is the purpose of the Vref in this opamp comparator circuit?
I was wondering what the purpose of the Vref is


What you have is called a differential amplifier and, the ratio of R3 and R4 should be the same as the ratio of R1 and R2: -



When you use a "ref" voltage instead of 0V the output from the differential amplifier is "referenced" to the ref voltage. A typical example might be to make ref = 2.5 volts and, when the sensor output is "neutral" or balanced, the output from the op-amp is 2.5 volts. This makes it suitable for connecting to an ADC that has a 5V input span range.

As you can see in the example circuit in the question, the op-amp is powered from 5 V and 0 V (earth) and so a ref voltage of 2.5 volts seems appropriate.


  Why not just input the Vout+ directly to the opamp?


If you did that you would lose your stable point of reference. I assume that the sensor is a 4 element bridge and that all four elements can vary depending on what is being sensed. If only two elements were active then you could use the junction of the static elements but you would also need to rely on your 5 volt supply being stable.