This circuit is
a Schmitt
Trigger, a type of comparator. It measures the input to see
if it is above or below a certain threshold. The threshold varies to
make it less likely that the output will switch rapidly back and forth
due to a noisy input near the threshold.

The input is a noisy 40 Hz sine wave, shown in the first scope. The
output is shown in the second scope. The third scope is a graph of
the output versus input.

Let's say the input starts at ground.
A voltage divider puts Q1's collector at about 2.1 V, and Q2's base at
about 1.5 V. Q2's emitter is at about 900mV, about a diode drop lower than its base.
Q2 is conducting, bringing the output low.

Q1's emitter is tied to Q2's, at 900mV, so Q1 will be off until the input rises
to about 1.5V. Once that happens, Q1 will conduct, bringing its
collector low, which will lower the voltage of Q2's base and shut it off,
bringing the output high.

If the input drops slightly below 1.5V, Q1 will stay on, because Q2 is
no longer keeping its emitter at 900mV. So a noisy input will not
cause the output to shift rapidly between high and low.

The input has to drop below about 1.1V in order to turn on Q2. When
this happens, the current Q1 is low enough that it comes out of saturation and goes
into forward-active
mode, and the voltage drop across it becomes large enough to
turn on Q2. Q2 shuts off Q1 and brings the output low.

If the input rises slightly above 1.1V again, this will not change the
output; the input has to rise above 1.5V to turn on Q1.

If the simulator says "Convergence failed" just click reload. The applet
often has trouble simulating this circuit.