To say that this tradition goes back "centuries" is to understate things a great deal. The tradition started long before that and it started long before coffins.
There is some dispute about what archaeological finds really prove that flowers were intentionally placed with dead people in graves (as opposed to having rodents or something bring it in). However, it is pretty well accepted that flowers have been found in a grave as long ago as 4,000 years before the present. (There is at least one Neanderthal burial site in Iraq where some archaeologists say flowers were placed in the grave -- this is from really long ago since Neanderthals died out around 30,000 years ago.)
Because the tradition started so long ago, there is no way to know why the people did this. A common explanation is that flowers signify the start of life. So putting flowers on a dead person would imply a hope that they would start a new life after death.