You can check the formulas but here is some intuitive explanation. Let's call the transistor on the bottom of the cascode transistor 1 and that on the top - transistor 2. If you have a simple current mirror (one transistor only) - both in cmos and bjt - the voltage at the output terminal of the mirror (drain or collector) can vary depending on the load. This as you know causes channel length modulation or base-width modulation (the Early effect). The modulation causes variation in the current - so, you have a variation in the voltage which causes variation in the current, which is in fact a caracteristic of a resistor - Ro of the transistor. If you can make the drain or the emitter voltage more constant , you'll have less modulation and hence the current generated by the transistor will stay constant. Now, in the cascode configuration transistor 2 acts like a source or emitter follower for the drain/collector of transistor 1 (transistor 1 is the load for this follower). If we connect the gate/base of transistor 2 to some relatively constant voltage we will also force its sourse/emitter to be constant as well. And transistor 1 sees just a small voltage variations at its drain/collector, so less modulation of the current i.e. the constant current generated by transistor 1 goes directly into transistor 2 and to the output. If the output voltage varies, those variations go as a variation in the Vds/Vce of transistor 2, but the current remains constant. Looking into the drain/collector of transistor 2 this is equivelent to a very big output impedance.