Borel (1972, J. Diffl. Geometry) proved that $f$ is always algebraic if $Y$ is the quotient of a bounded symmetric domain by a torsion-free arithmetic subgroup. This is a super-generalization of your example 3 (the quotient of the complex upper half plane by $\Gamma(2)$ is isomorphic to the projective line minus three points). The proof uses a generalization of work of Kwack plus the resolution of singularities.
Added: Kwack (1969) generalized the big Picard theorem by proving that any holomorphic map from the punctured unit disk into a hyperbolic complex space can be extended holomorphically to the whole unit disk. [A reduced complex space is said to be hyperbolic if the Kobayashi pseudodistance is a distance (Kobayashi 1967).]
Borel 1972 replaced the punctured disk in Kwack's theorem with a product of punctured disks and disks.
Resolution of singularities allows you to realize a smooth algebraic variety as an open subvariety of a smooth projective variety in such a way that the boundary is a divisor with normal crossings (hence analytically a product of punctured disks and disks).
These statements sometimes allow you to extend your map to an analytic map of projective varieties, where you can apply Chow's theorem to prove that it is regular.
References:
Borel, Armand. Some metric properties of arithmetic quotients of symmetric spaces and an extension theorem. J. Differential Geometry 6 (1972), 543--560.
Kwack, Myung H., Generalization of the big Picard theorem. Ann. of Math. (2) 90 1969 9--22.
Kobayashi, Shoshichi, Invariant distances on complex manifolds and holomorphic mappings. J. Math. Soc. Japan 19 1967 460--480.