I have a similar thing on my 99 S Type, if i open the boot before arming the alarm, often it will not arm/set. If i open and close one of the doors (drivers door usually) i can then set the alarm. I've put this down to perhaps a worn door open switch on the drivers door or possibly whichever module (BCM perhaps) not recognising all doors are shut. It sounds to me as if you have a similar problem brewing but in a later stage.
Also worth checking to see if it does it with your spare key, if it doesn't, get yourself a replacement spare and start using the spare key.