The palace and the residence do roughly the same thing. but they are better than each other at different times in the game. Both the palace and the resisdence protect your village against senators, chieftains and chiefs from conquering it. The higher the level the better they defend.
Palace (Prerequisites: Embassy level 1, Main building level 5)
This is good if you have it in your second village. This is because the residence is easier to upgrade at the start of the game. It is cheaper than the palace to upgrade. the palace cannot be destroyed but it can be damaged. Only one palace can exist in your realm at a time. Also only in the palace you can proclaim a village to be your capital. Only in the palace you can name a city your capital! The capital can not be conquered. Additionally only in this particular village the stonemason can be build and resource tiles extended beyond level 10. The palace is good in one way as it acts as a troop unit. Ask yourself have you ever seen an attack when someone attacks another person who defends with no troops and the attack still loses units. Thats the palace. the higher its level the more damage it does
Residence (Prerequisites: Main building level 5)
This is better to have in your first village as it is cheap to build and it takes less resources to upgrade. The downside is that it can be completly destroyed. Also if you have a residence you can build a great barracks and a great stable. The downside is that your city can be conquered and you cant extend the resources tiles beyond level 10.