Supercell just added heroes years ago and I don't know how these changes the games and all it does is attack and defend. What is their purpose?
In clash of clans, heroes are quite blatantly a boost for attacking. Heroes also unlock special abilities at level 5, which then, as you upgrade the heroes, their abilities will upgrade every 5 levels as well.
When The Barbarian King's special ability is used, he will enrage all barbarians in a short area around him, and also spawn [x] barbarians, [x] being determined by how high his ability level is.
the The Archer Queen will temporarily go invisible, and will not be able to be targeted by any defense or defending troops, and any towers or troops currently targeted on her will re-target. Along with this, she will spawn [x] archers where again [x] is determined by her ability level.
Finally, The Grand Warden. The ability of The Grand Warden will make all units (including other heroes) inside of a large radius temporarily invincible (cannot be killed). The Grand Warden can be set on ground mode, or air mode, and each mode will have different benefits.
On ground mode, the grand warden can glide over walls, similar to a hog rider, and will from a medium range target the closest building according to his A.I. On air mode, The Grand Warden will more gracefully fly around the map, so going over walls won't slow you down. Be careful with this, however, because when in air mode, The Grand Warden can be targeted by air defenses such as Air Defenses, Seeking Air Mines, and Air Bombs