Pre-Script: I am taking my reference to be ground every time I say voltage.
The 4.7k ohm resistor does the job of dropping the voltage when the transistor in on. When the base voltage is greater than the emitter voltage, the current (Ic) flows into the base. Assuming the current gain to be B, the current flowing into the collector is B(Ib).
Mathematically, Ic=B*Ib.
Ohm's law says V=IR. So the resistor must drop the voltage. How much voltage does it drop? Here, the transistor is supposed to work on saturation region. Meaning the collector-emitter voltage (Vce) is lowest possible. So almost all (but not all) voltage is dropped across the resistor. What you are left with is very little voltage at collector. And this is where the output is taken from.
Lets look at next scenario. If there was no resistor between the collector and the Vcc, the voltage drop must be provided by the transistor. You have Vcc at the collector and 0V at emitter. The transistor must drop all the voltage. Your output would always be high no matter what you provide at the input.

simulate this circuit – Schematic created using CircuitLab