For forex, the situation is a bit better - you can get information from Dukascopy/Tickstory for free. For cryptocurrency there is data available from Binance.
There is also QuantConnect, which is an online IDE/system for developing manually coded trade bots. They have historical data for a wide range of financial products and it's all available for free. The catch is that the data can't leave their system, which eliminates the possibility of training any sort of advanced machine learning model.
Edit: for these types of questions I would recommend searching /r/algotrading
In terms of pulling price history on-demand, Yahoo Finance seems to be a popular choice, but I don't think it will allow you to download a large enough dataset for meaningful training--that said, I haven't tried it, so I invite anyone to share their experience.
Additionally, you may want to try searching for the most cited papers for "ML in trading" and see what kind of datasets they use. Be prepared for a lot of gruntwork formatting the data before you feed it into your model: those papers might also give you a lot of context on how to do this gruntwork right from the first time.