No. There's no evidence it's an effective deterrent and thus serves no purpose other than that of primitive, bloodthirsty revenge.
Moreover, it is deeply hypocritical. Teaching that crimes like murder and rape are wrong by murdering (executing) someone defeats the entire purpose of trying to eradicate these behaviours. Two wrongs don't make a right, not now and not ever, as history has aptly shown.