Others have covered PRNGs commonly used in early machines, so I wanted to add some detail on hardware sources of randomness. Some machines do have dedicated, tested random number generators, but retro computers usually had to make do without them.
Computers with analogue inputs may be able to use those to generate random bits. Typically those inputs are somewhat noisy, due to limitations of the analogue-to-digital converters of the time and electrical noise. For example, the Atari 2600 and related machines could read analogue paddles for Pong style games, which worked by measuring the time it took to charge a capacitor. The charge rate was varied by a current limiting potentiometer in the paddle. Other machines like the BBC Micro had more advanced but still somewhat noisy analogue-to-digital converters.
Due to noise the lowest order bit of an analogue-to-digital conversion tends to be somewhat random on those systems. Sampling those bits, and using them to seed a PRNG can produce better results than just using a PRNG on its own.
Another common source of randomness was timers. Applications that were not synchronized to the screen refresh could often use registers in the graphic processor, like the current beam position, as a source of randomness. Depending on the application, it might only use the lowest order bit, for example if the current scanline is odd or even.
Measuring periods between user input was a popular technique. Times between key strokes, down to the millisecond or below level, are known to be fairly random. Mice are even better for this, although many users of early systems didn't have them.
Other more exotic sources of randomness included storage medium response times, for example how long a floppy disk took to seek during loading. Since the angle that the rotating disc started at was somewhat random, the overall time to seek to any particular track also varied.
All of these sources had their limitations, so were typically combined and used to seed a PRNG or entropy pool rather than being used directly.