This is non-trivial and you have not provided anything like enough details for an exact solution, but, in general terms the steps you need to take are:
Set up a default gateway on Y through X, without breaking the VPN connection. This is
probably a matter of adding a specific route for the VPN endpoint/subnet, and changing
the default gateway on X.
The firewall (if one exists) on Y needs to be modified to allow traffic to and from X.
packet forwarding needs to be enabled on (echo 1 > /proc/sys/net/ipv4/ip_forward)
should generally work.
You need to set up masquerading / NAT on server Y to rewrite the packets leaving it.
This will depend on your interfaces, but something like
/sbin/iptables -t nat -A POSTROUTING -o (Ext IF on Y, eg eth0) -j MASQUERADE
will usually work.
You may need to add MTU clamping if some sites work but others don't.
iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
Note that depending on your Internet requirements you might not actually need any of this - you may be able to use SSH to create a SOCKS proxy and simply use that (but that will only work if the Internet clients you are using on X support SOCKS). This is an order of magnitude easier to do for a one off if you can get away with it though.