Is there a reason that the Cylons attacked the Colonies on the day of the Galactica's decommissioning, or was that only a coincidence written for narrative reasons?
This post contains minor spoilers, I didn't bother using the tags to keep the layout simple and readable - plus they're really minor.
There are lots and lots of coincidences (or happenings guided by a higher being; however you'd like to call it) happening. Some of them are obviously linked to the anniversary, but not all of them:
- There's the 40 year anniversary of the end of the first Cylon War.
- The cylons specifically targeted the anniversary for their first strike, which is evident, considering there hasn't been any contact on neutral territory for those 40 years (as depicted in the opening of the pilot/miniseries). But this time there is a representant (a Six with at least two guards) and they blow up the "neutral" station with the diplomat. This probably wouldn't have happened if they'd started the war a week later or something like that. There haven't been any witnesses, but you don't have to risk it.
- Galactica is (one of?) the oldest Battlestar(s) still in service, so it's selected to become a museum.
- The Colonial Navy (or whatever it's called in the undubbed version) scheduled Galactica's official decomission/"last day in service" specifically to be on the day of the anniversary as well.
- Galactica is not "Cylon proof" in any way - not at all. This is also one main plot point in a later episode. It just happens that it's very old and most networked systems aren't active anymore (or probably removed already). You don't need all that stuff on a ship that's made into a museum. More evidence for this: Galactica had at least one wing of up-to-date (or almost up-to-date) Vipers that got destroyed almost immediately after they were shut down by Cylon Raiders (the fight where Boomer got away). The other, immune Vipers are there because of the (to be opened) museum. It's also hinted at, that they move the ships from the "museum hangar" to the still working launch bays. Later on they get new Vipers from the Pegasus. They know about the virus/manipulation, so they're able to harden them in advance.
- The Pegasus isn't immune either, however they happen to sit in the docks for network upgrades, so these are either offline and/or unusable and their Vipers are all docked up (so not lost in space). There are initial issues, but they finally manage to jump out just in time.
- The Cylons didn't expect any military ship to be immune against their electronic warfare, as depicted in the mini series. They try and fail against the outdated fighters, but they try to do so once again in a later episode (both when they network Galactica after jumping to the wrong coordinates as well as when they become aware of at least some of the Final Fives being in the fleet), despite their previous experiences.
- The Cylons never had any special plans regarding Pegasus and/or Galactica. Both ships and their crews were just really lucky they got away. They haven't been any specific part of the plan. Later on it's revealed that the Final Fives (or most of them) have been on the Galactica (or in its civil fleet) all the time. This, however, was another coincidence. Cavil didn't really care for them and the others didn't even know they could be there.
By this point, the Galactica had already been largely demilitarized. One of the hangars had been turned into a museum. Skeleton crew. Yadda yadda yadda. While one could argue that that the command staff were even more distracted on this particular day, the truth is that it had been just as vulnerable for weeks or even months.
So the day of decommissioning was not significantly more strategic than any prior. It seems very unlikely that this was more than a coincidence.
On the other hand, in Razor, we see a depiction of other battlestars in dock. It's plausible that the locations of those ships was taken into account in the Cylons' plans. But we have so few details in that regard that it can be nothing more than speculation.