To sail close to the wind is to take a risky course of action – on the edge of law-breaking or calamity.
In its original sailing meaning, to sail close to the wind means to steer the boat as near as possible to the direction the wind is cloming from.
If the wind were coming from the 12-o-clock direction close to the wind might be around 10-o-clock or two-o-clock. Going in those directions the sails will be full and the ship will travel along briskly. Just a small error in direction would point directly into the wind and the ship will abruptly lose wind and speed. Thus ‘close to the wind’ is exhilarating but risky.