Let me explain the process of prediction algorithms. The first step is collecting the data, which might or might not be processed. This is called historical data. This data is pre-processed and converted into human understandable data also called as information. This is called random sampling. Now the data is divided into training data and test data. The training data is used to train the model, as the name suggests and the test data is used for testing the predictions made by the model after training. If the predictions are accurate enough then the model works perfectly fine. If your model does not work then you have to retrain the model(It's an iterative process).
I hope it's clear why the dividing into training data and test data is required.