Hysteresis is just a difference between the voltage a comparator sees as 'high' and what it sees as 'low'.
Imagine a gradually rising signal, such as your sine waves. The voltage is easily measurable at any point so a threshold at which the comparator changes state is easy to visualize. Now add noise to the waveform, even the tiniest amount will create a point where (signal + noise) is above the threshold and (signal - noise) is below it so at the threshold point the comparator could rapidly change state in time with the noise. Note that even with a perfectly filtered waveform there will be noise in the comparator itself to contend with.
The hysteresis is to help remove the effect of noise. The amount of hysteresis should be at least equal to the peak value of the noise so the switching points (upper and lower thresholds) are so different that the noise voltage cannot alone change the comparator output.
You don't have to use hysteresis, it depends upon your application, some systems are tolerant of rapid comparator switching, some are not. It's a tool to help to keep signal clean.
Some phase shift is inevitable because of the time delay while the signal reaches the hysteresis difference. You have to make a compromise between noise immunity and how much shift you see. Obviously, minimize the amount of hysteresis if possible.
Brian.