These verbs both mean to put someone or something in the place of another. To replace is to be or to furnish an equivalent or substitute, especially for one that has been lost, depleted, worn out, or discharged:

To replace:

to provide a substitute for (something broken or unsatisfactory, for example) - AHDEL

To substitute:

To put or use (a person or thing) in place of another - AHDEL

While the two are synonyms, replace does carry a stronger connotation of being long-term.

The etymology of substitute, particularly the prefix "sub" may suggest why it has a weaker connotation of being permanent:

Origin

late Middle English (denoting a deputy or delegate):

from Latin substitutus 'put in place of',

past participle of substituere,

sub 'under + statuere 'set up'.

Substitute is rendered from it's Latin origin: "set up under"

PREFIX

1 At, to, or from a lower level or position:

subalpine

1.1 Lower in rank:

subaltern

subdeacon

Although permanent replacement is CURRENTLY an acceptable use of substitute, it's original use was closer to "deputy". A substitute would stand in for the principle as a duputy:

  • a deputy "replaces" the sheriff who ordered him to execute the warrant
  • the corporate vice-president "replaces" the president who is out of town
  • margarine "replaces" butter when it is not available
  • a temp "replaces" the secretary while she is on vacation

Each of those "replacements" is temporary because the principal remains available "above" her substitute.

Edited to add: As @John Lawler points out, they are the same but serve opposite rhetorical functions: he replaced 'old' with 'new'; he substituted 'new' for 'old'.