Olá - Hello
Mão - Hand
Avô - Grandfather
Avó - Grandmother
They have four functions:
1) To indicate the correct sound.
2) To indicate the stressed syllable.
3) To turn a diphthong into a hiatus.
4) To distinguish critical words.
The full set of rules are a little bit complicated.
If you want it, ask me for it, and I will give you some material.