Why doesnt your heat work when sitting idle but works when driving?

It has a lot to do with the fact that the heat provided when you turn the heater on comes from the engine. the faster your engine is reving the more heat you'll get. Next time try putting the car in neutral and revving the engine. that should get you some more heat.