Questions.
When did humans develop the ability to sail any direction regardless of wind direction?
Short Answer:
The Anglo Saxons Norsemen, early Vikings would have been the first to travel close to the wind sometime in the 6th century. Without a keel one can't sail close to the wind. The sail configuration is less important than the ability to steer and ability to stabilize the ship and not slide when being pushed by the wind sideways. This important invention (keel) some historians believe was the first word in the English Language recorded in writing. The keel the Vikings invented with a shallow draft capable of traversing rivers, would have only been useful for sailing close to the wind.
Detailed Answer:
The nautical term would be all points of sail
Sailing ships even today cannot sail all points of sail (any direction) regardless of wind. All sailing ships have a no-go angle into the wind. Generally that no-go angle is 45 degrees on either side of directly into the wind although different rigging can diminish the no-go angle. Sailing close to the no-go angle is called Close-hauled. Sailing into the no-go is called sailing in irons or basically the sails generate no power and the ship's forward momentum stalls.

Sailing ships only appear to sail all points of sail by iteratively sailing back and forth while changing their angle to the wind. It’s called tacking or coming about. That describes the movement of the beam and sail as a ship passes through or around the no-go angle.
tacking
Tacking or coming about is a sailing maneuver by which a sailing vessel, whose desired course is into the wind, turns its bow toward the wind so that the direction from which the wind blows changes from one side to the other, allowing progress in the desired direction.
Jibing, or wearing is when you are running downwind and the sails change sides..
Jibing
A jibe (US) or gybe (Britain) is a sailing maneuver whereby a sailing vessel reaching downwind turns its stern through the wind, such that the wind direction changes from one side of the boat to the other. For square-rigged ships, this maneuver is called wearing ship.
Bottom line though even square rigged primitive ships could travel into the no-go angle it just would have taken them more iterations as their no-go angles where greater and more time to configure their sails. However; any ship capable of sailing beyond a beam reach or having a no-go angle less than 90 degrees, close reach is capable of sailing up wind with enough iterations.
So before one can steer back and forth across the no-go angle one must be able to steer. Before one can steer a few things had to be invented.
The invention of the stern-mounted rudder is credited to the Chinese, 1050 BC – 256 BC
The Keel. A structural beam that runs from a ship’s bow to its stern and sits lower than the rest of the hull, the keel was first invented by those intrepid Norse sailing men known as Vikings.
It would be the Vikings who would have been the first to sail a bream reach and perhaps close reach.

square rigged viking ship close hauled.
They had both the rear rudder and the keel, their sails perhaps would have required more time to tune for different points of sail; but without a rear rudder and keel traveling a beam reach is not possible as you will just sail sideways. It's your keel and rudder as much as the sail that allows you to travel a beam reach. Also importantly for answering this question, If one is not sailing a beam reach, their was no reason for them to have invented the keel. The keel serves two purposes on a modern sailboat. It keeps you from sliding sideways when on a broad reach, and it keeps your boat steady serving as a counter balance to capsizing. Only the Vikings keel was shallow and didn't have a counter balance, thus its utility was only for sailing close to the wind.
.
10 Top Innovations in the History of Sailing
A structural beam that runs from a ship’s bow to its stern and sits lower than the rest of the hull, the keel was first invented by those intrepid Norse sailing men known as Vikings. Because their sailing ships were square-rigged, they were prone to making a lot of leeway when tacking close to the wind. The addition of a keel prevented this lateral movement, increased speed and made Viking ships more stable.
What do we know about Viking Longships
Viking longships were among the first to have a keel.
.
Keel
The word "keel" comes from Old English cēol, Old Norse kjóll, = "ship" or "keel". It has the distinction of being regarded by some scholars as the very first word in the English language recorded in writing, having been recorded by Gildas in his 6th century Latin work De Excidio et Conquestu Britanniae, under the spelling cyulae (he was referring to the three ships that the Saxons first arrived in)
.
English History
There is only one known account of the Englisc Conquest, from a native Romanic-Brython that may have endured that time Gildas (c. 494 or 516– c. 570) was a popular member of the Brython Christian church in Britain, whose prominent knowing and also literary style earned him the designation Gildas Sapiens (Gildas the Wise). He defines the response of the Romano-Brythons to the repeated strikes by Gildas describes the sacking of Southern Britain by the Anglo-Saxons thus:.
.
Viking Ships
The boat-types were quite varied, depending on what the ship was intended for, but they were generally characterized as being slender and flexible boats, with symmetrical ends with true keel.
Boats of the World: From the Stone Age to Medieval Times page 308
- the earliest keel(rather than plank keel) comes from thirteenth century China,
- The Lateen triangular sail.
While not a must for sailing close reach it would have been for sailing close haul and a significant improvement to sailing technology. We don't know who, when or where the Lanteen sails were invented, but we do know The Greeks were using them in the first century BC.
From Comments
@PieterGeerkens Square rigged ships sailed against the wind by using their fore-and-aft sails, with the square sails furled. The square sails could not manage more than a beam reach.
.
Pieter No sail configuration will permit you to sail a broad reach without a keel.
Know How Sailing 101
how does a boat make progress sailing across the wind or even toward the wind? ...A sailboat would slide sideways with the wind if it did not have a centerboard or keel underneath the hull.
.
Point of Sail
The higher the boat points into the wind, the stronger the lateral force, which results in both increased leeway and heeling. Leeway, the effect of the boat moving sideways through the water, can be counteracted by a keel or other underwater foils, including daggerboard, centerboard, skeg and rudder.
.
Close Hauled
The curve of the sails is in the shape of an airplane’s wing, generating lift—a force that, in combination with the effect of the keel, results in the boat being pulled forward.
And while a fore and aft sail configuration (nautical terms jib and mainsail) is more efficient there is no reason a square rigged ship capable of sailing a broad reach can’t sail beyond that by the same means it achieved the broad reach; by turning the sails sideways. –
Here is a square rigged boat close hauled (see sail relative to deck and then check sail configuration in above chart).

David Harding sets up a direct comparison between Junk- and Bermudan-rigged Splinters to find out how they handle. Which is best – Bermudan rig vs junk rig? The answer, of course, is neither. Or, perhaps, both. It depends what you want.
@slebetman - Windmill ships (where the windmill is linked to a propeller) can sail directly upwind and have no no-go angles.
I don't think that's accurate. I don't think a windmill attached to a propeller would generate enough force to push a boat forward directly into the wind without a battery. Typically windmill ships use wind to charge batteries and those batteries are used to run electric motors, which to my mind make them motor boats or electric boats. It's arguable.
To consider them is arguing an exception. That doesn't make you wrong I'm just less interesting in discussing the exception over the rule.
From PieterGeerkens @JMS: Your quote is "No sail configuration will permit you to sail a broad reach without a keel." Note "broad reach" Not "close reach" and not "* beam reach*". And planing dinghys regularly beam reach in a good stiff breeze with their centre-board nearly retracted and just their rudder and hull acting hydrodynamically.
And Your quote was square sails could not manage more than a beam reach, which is false.
As for my quote, that's right Pieter, without a center board you can't sail against the wind regardless of sail configuration. No broad reach, no beam reach no close haul. The Center board is what gives the boat the ability to resist the wind and sail at an angle to it.
Planing dinghies? Not sure what you mean by that.. perhaps you mean what I am familiar with as healing, when a sail boat is on a beam reach or close hauled and the boat leans over? Couple of thoughts.. nearly retracting the centerboard is not the same as retracting it or having no centerboard in the water, and yeah you can't heal without a centerboard either. The reason to retract the center board after your boat is healing is to allow the boat to slide with the wind and to stop healing. Healing is risky because yo can tip, healing is difficult to control. and most importantly healing is inefficient and in a race costs you speed. Raising the center board slightly is an attempt to flatten out the boat to get it to sail at a more efficient angle to the water (flat).
Raising the Centerboard
he centerboard works with the sail to drive the boat forward. It's providing resistance against the water sideways and once the boat starts moving forward, generates lift. One of the results of this is a heeling force.
The best way to visualize (or do it in actual conditions) it. Sailing upwind, pull the board up all the way - the boat will slip sideways, loose forward drive, and require much less weight to keep the boat upright. So now we know that we can reduce heeling force by raising the centerboard - But, we also learn that we loose some lateral resistance, ie we slip sideways instead of going forward.
So, the idea of raising the board 2-4 inches when you can no longer hold the boat down is an attempt to reduce the lateral resistance enough to get keep the boat flatter. You will point a little lower, but won't actually won't be slipping sideways
You can't make forward momentum against the wind without a centerboard or keel, as a rule. There are exceptions generally with smaller lighter boats ( over sized rudders, specialized hulls) which I won't go into because they don't really pertain to the Question. For ancient square rigged ships what limited their ability to sail against the wind was not their sails, it was the lack of keel. Square rigged ships were less efficient and took longer to configure for different points of sail, but with a keel they could do it.. They do do it, as I've demonstrated above.