Delta mesure the slope of the digital option.It also provides hedging information. Why do we only need to buy or sell stock to hedge when the underlying is close to the strike?
This is due to the payoff structure of the digital option. The payoff is nothing while the option is out of the money and then instantly goes to a fixed payment amount when it is in the money. It does not gradually increase as the option becomes increasingly in the money like a plain vanilla option.
What makes these options difficult to hedge is that the gamma switches sign at the strike. It is an inflection point and the delta becomes very high as the option becomes at the money, only to start declining as the option becomes in the money. So a delta hedge for a long digital call requires shorting increasing amounts of stock as the underlying approaches the strike and then buying it back as the option becomes in the money.
In the case of a digital or vanilla option, buying or selling stock to hedge an option only eliminates delta risk. Notably, when the strike is near the underlying price, gamma risk is particularly high. I.e., the change in delta is highly sensitive wrt to a change in the underlying. As AIRacoon points, gamma exhibits particularly asymptotic behavior digital as the strike nears the underlying.
Black-Scholes is derived by the delta hedging argument because it eliminates risk if and only if trading is costless and frictionless, and if markets are complete (see Fundamental Theorem of Asset Pricing). Only by eliminating the drift component does the Black-Scholes differential equation (basically the Kolmogorov and/or Feynman-Kac PDE) have a risk-free probability distribution.
In reality, however, none of these conditions are fulfilled. An options position which is continuously delta hedged will almost surely incur excessive trading costs. Thus, in the real world, it isn’t not necessarily true that we only need to buy or sell stock to hedge an option.