The word O, sometimes spelled Oh, can as here in the Shakespeare quote above serve as a vocative particle. The OED gives its first sense as:
1. Standing before a sb. in the vocative relation.
The etymology is interesting:
A natural (or what now seems a natural) exclamation, expressive of feeling. OE. had neither ó!, nor á! (which would have phonetically given ME. ô!). Not in OHG., or early ONor.; in Goth., prob. from Greek; in MHG. and later (Christian) Norse, prob. from Latin. In early ME. 12th c., app. from L. (or ? Fr.); but often varying with A!, esp. in northern writers. Wyclif has O (or A) only when O is in the Vulgate. In OE., Lat. O was rendered by lá or éalá.
Colloquial English doesn’t use a vocative oh much. It sounds old-fashioned.
- O Death, where is thy sting? O Grave, where is thy victory?
But you still find it in poetry, of course:
- 1850 Tennyson In Mem. iv. 5 ― O heart, how fares it with thee now?
When spelled O, it must be capitalized; when spelled oh, it is only capitalized when it falls at the start of a sentence.
There is another, interjective sense of oh that we do still use colloquially.
The OED says of this second sense:
2. In other connexions, or without construction, expressing, according to intonation, various emotions, as appeal, entreaty, surprise, pain, lament, etc. In this use, in 17th and 18th c., often written oh (q.v.); but this form is now usual only when the exclamation is quite detached from what follows (see oh); O being used with an imperative, optative, or exclamatory sentence or phrase, as in O take me back again! O would I were there! O that I might see him! O for another glimpse of it! O the pity of it! O dear me! O dear! O me!; often also in O yes, O no, O indeed, O really, and the like.
And here are some more Tennyson citations:
- 1842 Tennyson ‘Break, break’ iii, ― O for the touch of a vanish’d hand.
- 1850 Tennyson In Mem. xxxv, ― O me, what profits it to put An idle case?