It's all based on how random number generation in computers works.
Basically, computers always follow the programming rules, they can't do anything actually random. So when the game needs to do something random, like pick which fish you'll get or where the ladders are in the mines, what it does it take some starting number and apply a bunch of math formulas to it, so that the resulting number it spits out seems random if you don't know what it's doing. This process is called "random number generation", or RNG.
So when you start a new file, it gets assigned a 9-digit number called the seed. Then this number is used as the starting point for the RNG calculation. (Well, actually it's usually that number combined with a few other things, like the in-game day, the number of steps you've taken in game, or the coordinates of the rock you're breaking. So the actual starting number for the RNG is different each time, it's not just the seed number every time. But the seed is part of it.) By the way, on PC, you can see the seed for your game by going to %appdata% in File Explorer, and then going to Stardew Valley/Saves. This will show all your save files. The number in each folder name is the seed number.
This means that if you're given the seed number for a game, and if you know exactly what the RNG is doing, you can predict a lot of things about it. For example, you can predict what will come out of geodes, or what the travelling cart will sell on each day. This is too complicated to do by hand (or at least I don't know how), but a lot of this is shown on the website "Stardew Predictor", although the author of that website seems to have disappeared so I don't know if it will be updated for 1.5.
Normally, the seed is picked based on the time when you create the save file. With this tool, you can manually set the seed to whatever you want. This is not super useful in most cases, but it's good for if you're having a competition with a friend and you want to get the same stuff in the cart, geodes, etc. It's also good if you know a certain seed is going to give you stuff you want (e.g. maybe you want some CC items to show up in the cart early).