Why does heat engine need to reject energy to environment? The most efficient thermodynamics cycle is the Carnot cycle, it involves
1/ Receiving heat from hot source, expanding and doing work on the surround
2/ Receiving work from environment, being compressed and rejecting heat to surround.
So the efficient is limited by $n = \frac{(T_H - T_C)}{T_H}$ where $T_H$ and $T_C$ are absolute temperature of hot and could source.
In the cycle, there is a step where heat engine receiving work from surround, thus lower the total work it can do. The question is, why does heat engine need that, why just ignore that, e.g. don't compress the gas so don't waste that work?
For example, let say we burn oil to heat air, the air is expanded and turn a turbine. We don't compress gas so any heat that air received will do work on the turbine.
By doing so, all received heat will be transfer to work, isn't it?
Why does every heat engine need to re compress gas to do the negative work on the environment?
 A: 1)You must have clear on your mind that engines do not work on any thermodynamic cycle.Per example, a diesel engine "consumes" fuel and air and expels an equal amount of exhaust gas. Nothing returns to the beginning. Even a rankine cycle that i saw on comments produces superheated steam and the boiler receives cold water and it is certainly not the same
2)Engines have cooling systems and this is a practical consideration. This is the way to protect the metals or the materials that compose the engine.Engines either reject heat or melt.Nothing prevents from heating an engine instead of cooling it, giving entropy instead of rejecting it except the strength of materials
3)I also want to ask you how an engine that does work ( changes volume ) will expand the working substance (air,gas,steam, anything) without compressing it first.
A: Heat engines are supposed to be cyclic, so that after one cycle, the state of the engine itself is exactly where it started. If you don't expel heat, you can only get back to the initial state by undoing whatever you just did, so the cycle does zero net work. Expelling heat lets you get a positive area in your PV curve. 
This argument doesn't apply to burning oil, because that's not a cyclic process.
A: As asserted by knzhou in his answer, heat engines work in cycle and that's why it has to dump entropy before starting a new cycle (and that is the final nail in the coffin of perpetual motion of second kind).

Let $\delta Q_\textrm{H}$ be the amount of thermal energy that is taken up by the system from the hot reservoir. Therefore, entropy change of the system and reservoir respectively:
$$\mathrm dS_\mathrm{sys}= \frac{\delta Q_\textrm{H}}{T_\mathrm{sys_H}} \\ \mathrm dS_\mathrm{hot \,res}= \frac{-\delta Q_\textrm{H}}{T_\textrm{H}}$$ 
Now, since, it operates in a cycle, this must mean it has to dump that extra entropy $\mathrm dS_\mathrm{sys}$ as the net change in entropy after a cycle is zero viz. $$\Delta S_\textrm{cycle,sys}= 0\;.$$
In order to achieve this, the system dumps this extra gained entropy by giving off thermal energy to the cold surroundings or cold reservoir. 
The entropy change of the system and entropy change of the cold reservoir respectively as: $$\mathrm dS_\mathrm{sys}= \frac{-\delta Q_\textrm{C}}{T_\mathrm{sys_C} }\\ \mathrm dS_\mathrm{cold \,res}= \frac{\delta Q_\textrm{C}}{T_\textrm{C}} \;.$$
Now, $\Delta S_\textrm{cyc,sys}= 0$ means 
\begin{align}\mathrm dS_\textrm{universe}&\ge 0\\ \implies   \mathrm dS_\textrm{sys} + \mathrm dS_\textrm{res} &\ge 0\\\implies  \underbrace{\left(\frac{\delta Q_\textrm{H}}{T_\mathrm{sys_H}}+ \frac{-\delta Q_\textrm{C}}{T_\mathrm{sys_C} }\right)}_0 + \frac{-\delta Q_\mathrm{H}}{T_\textrm{H}}+\frac{\delta Q_\textrm{C}}{T_\textrm C}&\ge 0\\ \implies \frac{Q_\textrm C}{Q_\textrm{H}}& \ge \frac{T_\textrm C}{T_\textrm H}\tag{1}\end{align}
Now, $$W= Q_\textrm H- Q_\textrm C$$ and efficiency $$e\equiv \frac{\textrm{work}}{\textrm{heat absorbed}}= \frac{Q_\textrm H-Q_\textrm C}{Q_\textrm H}\tag 2$$
Using $(1)$ and $(2)$ we get $$e\le 1- \frac{T_\textrm C}{T_\textrm H}$$

So, how does the last result come?
It came because of the second law and that the change in entropy(a state variable) of the system/engine is zero over a thermodynamic cycle.
A: Let us assume a gas at $300~\mathrm K$ (ambient)and volume $100~\mathit l$ heating it upto $600~\mathrm K$ will raise the temperature of gas to $600~\mathrm K$ and will cause it to expand twice its volume to $200~\mathit l$ (will push the piston or turbine).
But it all stops at this point ..... now you have a raised piston and gas at $600~\mathrm K$ now either you keep the gas or reject it to atmosphere, you will lose the heat to the surrounding at $300~\mathrm K$ because the gas cannot expand more and it has already been heated to $600~\mathrm K$.
Now we try to cool that air so we can extract more work and then we realise that cooling is actually a fancy word used for rejecting heat. And any rejection brings our engine efficiency down.
