I kept thinking that at the end of the sixth book. Dumbledore could search for the remaining horcruxes more easily if everyone thought he was dead.
Dumbledore was most adamant that Harry GET SNAPE when it became evident the situation had gone bad.
I reckon Snape and Dumbledore had it worked out in advance to fool everyone.