The riderless horse in a military funeral was an ancient custom practised by the Romans.
A soldier and his horse trained to fight as one unit in battle, making it almost impossible for the animal to have another master.
If a soldier retired, so did his horse.
For the same reason, if the soldier died in combat, the horse followed his coffin to the cemetery to be put down and buried with his companion.
The two would ride together into the afterlife.
The empty boots in the stirrups is a later tradition and signifies that no one else can ride that horse.
Today it’s simply a ceremony, and the animal isn’t harmed.