Question: I was wondering which gas would behave most ideally out of $\ce{H2},$ $\ce{He},$ $\ce{CO2}.$ All gasses are in the same condition.

I know the answer is either $\ce{H2}$ or $\ce{He}$ because of London dispersion forces. I was wondering which one it was and why.

Answer: 
In the simplest model, a gas is called ideal when its particles are point-like (no volume) and have no interactions. Real gases behave like ideal gases at low pressure (where the particle volume is neglible compared to the total volume) and high temperature (where condensed phases, i.e. interatomic or intermolecular interactions are disfavored).

The size-comparison between helium and dihydrogen is straightforward: Dihydrogen is larger. As for the strength of interparticle interactions, we can compare normal boiling points: Helium's is 4 Kelvin and dihydrogen's is 24 Kelvin.

So this would suggest that helium is "more ideal" as it has the lower boiling point and the smaller size.
A straightforward way to evaluate ideality is to compute the compressibility Z:

$$Z=\frac{PV\_m}{RT}$$

Z equals 1 for an ideal gas, so deviations from this condition serve as a measure of non-ideality. If you examine a plot of compressibility for a real gas you will in general notice the existence of two regimes: at low pressure the compressibility is smaller than 1 and shows a minimum before rising again and eventually exceeding 1. The deviation from ideal gas behavior at low P is due to attractive interactions whereas deviations at high P are due to repulsive excluded volume interactions. 

One way to infer ideality is to check van der Waals gas parameters. The following are the critical point parameters and vdW parameters for the gases: 

$$
\begin{array}{|compound|T\_c|P\_c|} \hline \textrm{compound}&T\_c/\pu{K}&P\_c/\pu{bar}&V\_c/\pu{L\*mol^-1}&a/\pu{L\*mol^-1}&b/\pu{bar\*L^2\*mol^-2} \\ \hline \ce{He} &5.195 &2.275&0.0578 &0.0346&0.0237 \\ \ce{H\_2} &32.938&12.838& 0.065& 0.2465&0.0267 \\ \ce{CO\_2} &304.14& 73.843&0.094&3.655&0.0428\\ \hline \end{array}
$$

Since helium has the smallest critical volume $V\_c$, it also has the smallest van der Waals parameter $b$ (the covolume) and is expected to have the smallest hard-sphere radius. Helium also displays the smallest value of the van der Waals parameter $a$ which reflects the strength of attractive interactions, important at low pressure. This is consistent with helium being the smallest closed shell (inert) monoatomic (spherically symmetric) noble gas, and nearest among the gases to a point particle. If the van der Waals parameters are used to predict the compressibility coefficient (which they might do qualitatively if not quantitatively) using [a freely available Matlab function](https://se.mathworks.com/matlabcentral/fileexchange/35874-compressibility-factor-calculator) the following figure is obtained at 50 K:

[![enter image description here](https://i.stack.imgur.com/5ul2I.png)](https://i.stack.imgur.com/5ul2I.png)

Clearly helium shows the smallest deviations from Z=1 and therefore behaves most ideally.

As hinted in a comment, $\ce{CO2}$ is solid at the temperature and pressure displayed in the above figure. At 250 K however it's behavior is still quite non-ideal:

[![enter image description here](https://i.stack.imgur.com/X0Yat.png)](https://i.stack.imgur.com/X0Yat.png)

Interestingly, at 250 K hydrogen is more ideal than helium (if only slightly so), if the vdW prediction is to be trusted. 

An interesting aside is that helium has the lowest values of critical temperature $T\_c$ and critical pressure $P\_c$.