VCMI engine is free and open source software licensed under GPLv2.
Original game assets (music, sprites) are proprietary and you have to buy them in order to play. There actually Heroes 3 Mac demo that can be legally used as alternative source of Heroes 3 game data, but it missing some towns.