If you take a look at the atmospheric circulation pattern, the Hadley Cells in particular, they tell the story. The northern edge of Africa is on the descending edge of a Hadley Cell, which means
Having lost most of its water vapor to condensation and precipitation
in the upward branch of the Hadley cell circulation, the descending
air is dry. As the air descends, low relative humidities are produced
as the air is warmed adiabatically by compression from the overlying
air, producing a region of higher pressure.
The main air mass being dry already, and the High pressure system generated by the descending air mass along the 30 degree lines work to make the physics required for precipitation just not want to happen in these regions. You have to get a combination of enough humidity to reach saturation, and then cool the air to reach its dew point. The desert region formed by the lack of atmospheric moisture(remember Hadley cell) can't add any humidity of its own through evaporation or transpiration, so the global patterns dominate, even being right on the oceans edge.
Note that Hadley cell edges at the 30 degree south also cut through the Namib,Kalahari, and in South America the Atacama deserts, with their own ocean exposure.