It is very common that we don't insert a comma before a subordinate clause at end position as follows:
The President was opening a new university when a bomb went off.
However, I came across the same construction with a comma:
The President was opening a new university, when a bomb went off.
My question is, what is the function of the comma in the above construction?