We should not sleep under a tree at night because of the following reasons.
At night photosynthesis does not occur, oxygen is not being produced by the tree at night. In addition to this, continuing respiring thereby causes the amount of carbon dioxide to be increased and the amount of oxygen to be reduced.
At night, since the stomata (small openings in leaves) on a leaf are closed, there is no gaseous exchange taking place. Therefore, there is neither oxygen (O2) nor carbon dioxide (CO2) present around a tree at night.
At night, trees produce a lot of water vapor which causes the area below the tree to be very humid. This will mean that there is lesser oxygen available in the area for breathing.
At night, trees give out some toxic and undesirable gases such as sulfur dioxide gas. This can be harmful to humans as well as other life forms on the surface of the earth. So it is not advised to sleep under a tree at night.