Answer:
The "Physics" reason is that Carbon Dioxide absorbs radiation mainly in the infrared part of the spectrum, while nitrogen and oxygen do not. To help you understand this, first look up the "Maxwell-Boltzmann distribution". This shows you how the frequency of light from a warm object is distributed. The distribution peaks at a frequency which depends on the temperature of the object. The sun is very hot and emits mainly at frequencies that correspond to the light we can see. This passes straight through the atmosphere and warms the earth.
The earth is much colder by comparison and emits radiation mainly in the infra-red just like people do - which is why they use infra-red cameras to find people trapped in buildings. But this radiation is very strongly absorbed by CO2, which heats up. Other compounds behave similarly, in fact many such at methane absorb infra-red radiation much more strongly and so have a greater "global warming potential". Water vapor also absorbs IR and contributes to the greenhouse effect. However the total effect it has is much less simple because water vapor is involved in the water cycle. Water absorbs heat, but also releases it when it cools and condenses for form clouds and rain.