Let $f:X\to Y$ be your morphism of algebraic varieties over the field $k$.
a) By considering the restricted mapping $f^{-1}(Y_i) \to Y_i$ where $Y_i\subset Y$ is an irreducible component of maximal dimension , you reduce to the case where $Y$ is irreducible .
b) If $X_j$ are the finitely many irreducible components of $X$, you have $Y=\cup f(X_j)$, hence $Y=\cup \overline {f(X_j)}$, so that one of the $f(X_j)$ is dense in $Y$.
In other words by considering $f|X_j: X_j\to Y $ you reduce to the case that $X$ is irreducible but you must weaken yout hypothesis to $f$ is dominant (that is with dense image) instead of $f$ is surjective. Don't worry : we'll still manage!
c) Since the morphism $f:X\to Y$ of irreducible varieties is dominant, it induces a morphism of the corresponding function fields $f^* :Rat(Y) \to Rat(X) $ .
This implies by pure algebra (field theory!) the inequality on transcendence degrees over $k$ : $$trdeg_k (Rat(Y))\leq trdeg_k (Rat(Y)) \quad (*)$$
d) Finally, for an irreducible variety $Z$, we know that $dim (Z)=trdeg_k (Rat (Z)$ (this is essentially a corollary of Noether's normalization theorem). If you take this into account, $(*)$ yields the required inequality $$ dim(Y)\leq dim(X) \quad (**) $$
Edit The above works for all algebraic varieties, affine or not. Actually I hadn't even noticed that the OP mentioned affine varieties when I answered the question!