A hopeless or desperate enterprise.
Most of the phrases that are explained on this site are idioms - the expressions that make English so rich and enjoyable to converse in and, to the frustration of students of it as a second language, so difficult to learn. Idioms can be defined as those phrases that can't be understood from knowing what their constituent words mean. For example, English learners might know what skeletons and closets are, but still scratch their heads over 'a skeleton in the closet'. Alternatively, 'keep off the grass' isn't an idiom as, if you know what 'keep off' and 'grass' mean, you understand the expression. 'Forlorn hope' appears not to fit the definition of idiom but, as we'll see, it turns out to be one.
Lack of hope must have been a commonplace feeling amongst the English in the 19th century as they coined a variety of literal phrases to express it - 'not a hope in Hell', 'some hopes', 'what a hope' etc. To that list we might expect to add 'forlorn hope' as, using the above rationale, its meaning is defined by the literal meaning of 'forlorn' and 'hope'.
'Forlorn hope' now just means 'lost hope'. That's not how it was in the 16th century, when a forlorn hope wasn't a world-weary feeling but a robust and gung-ho band of soldiers.
Each troop in the British Army had a hand-picked group of men, chosen for their ferocity and indifference to risk (and occasionally by using that tried and tested military method of "I want three volunteers. You, you and you."). They were the army's 'attack dogs' who risked all in reckless death or glory raids on the enemy.
The Anglo-Norman terms 'avant-garde' and 'reregard' were adopted into English as 'vanguard' and 'rearguard' in the 14th century. They were the names of the forces that attacked from the front and protected the rear respectively. It seems reasonable to expect a group called the 'avant-garde' to have been the first into battle but, before them, went the 'forlorn hope'. These soldiers, also called the 'forlorn boys' or 'forlorn fellows', were given little hope of survival by their peers. The first mention of them in print is found in Raphael Holinshed's Chronicles of England, Scotlande, and Irelande, 1577:
Fortie or fiftie forlorne boies.
Soon afterwards, the method of attack was described in John Dymmok's A Treatise of Ireland, circa 1600:
Before the vantguarde marched the forelorn hope consisting of 40 shott and 20 shorte weapons, with order that they should not discharge vntil they presented theire peeces to the rebel breasts in their trenches, and that sooddenly the shorte weapons should enter the trenches pell mell.
That's the militaristic side of things, now back to the idiomatic. The equivalent group of combative soldiers of the Dutch army were called the 'verloren hoop', literally 'lost troop'. A bit of impromptu mistranslation amongst the British military turned this into 'forlorn hope'. The British Navy took the mistranslation a step further and their wildmen were known as the 'flowing hope'. The phrase was tortured still further and those who were sacrificed whenever the rearguard was called on to retreat were called the 'rearlorn hope'.
Although the original meaning of 'forlorn hope' is largely lost to us now, it was still in use in 1920 when John Galsworthy wrote in The Forsyte Saga:
"And round Crum were still gathered a forlorn hope of blue-bloods with a plutocratic following".
As time progressed, a forlorn hope was thought of as something one experienced rather than something one belonged to. The 'rearlorn hope' took no such linguistic journey and has stayed exclusively within the army.