It is a very simple device that generates random looking number. However, it is not really random at all if you know the formula and only the 'creator' knows the number. The device has a clock that changes to the next number at known time intervals. If you didn't type the number in fast enough, the website would deny access expecting the next number.
this is related to encryption and authentication.
The bank site gives you a different number every time. This is done with the help of a random number generator which will give you always a different and a random number so that no one can guess it.
You enter this in your security device given by bank along with your pin code. This will be encrypted and another number will be given as output.
When you enter this number generated by bank security device, the bank's server also calculates this to see if you have entered a correct number.