Using precise galaxy stellar mass function measurements in the COSMOS field we determine the stellar-to-halo mass relationship (SHMR) using a parametric abundance matching technique. The unique combination of size and highly complete stellar mass estimates in COSMOS allows us to determine the SHMR over a wide range of halo masses from $zsim0.2$ to $zsim5$. At $zsim 0.2$ the ratio of stellar-to-halo mass content peaks at a characteristic halo mass $M_{rm h} =10^{12} M_odot$ and declines at higher and lower halo masses. This characteristic halo mass increases with redshift reaching $M_{rm h} =10^{12.5} M_odot$ at $zsim2.3$ and remaining flat up to $z=4$. We considered the principal sources of uncertainty in our stellar mass measurements and also the variation in halo mass estimates in the literature. We show that our results are robust to these sources of uncertainty and explore likely explanation for differences between our results and those published in the literature. The steady increase in characteristic halo mass with redshift points to a scenario where cold gas inflows become progressively more important in driving star-formation at high redshifts but larger samples of massive galaxies are needed to rigorously test this hypothesis.