The Kli Yakar understands the pasuk to be saying that it is sometimes permitted to drink wine but sometimes prohibited. It is prohibited when one is “going into the Ohel Moed”, meaning that an intoxicated person may not enter Hashem’s house to daven. It is, however, permitted to drink wine for Kiddush and Havdalah at the beginning and end of Shabbos. This is stated at the end of the verse, with the words: “To distinguish between holy and mundane”, which can be understood as a reference to the times when we separate between Shabbos and weekdays, i.e., Kiddush and Havdalah. Even then, however, one should not drink excessively and become very drunk. There still should be a separation between pure and impure, meaning that the drinking should be in a pure way that will not lead one astray.
It is said in the name of Ropshitzer Rebbe zy”a that this pasuk contains a hint to all of the times that eating is considered a seudas mitzvah and, at these times, it is also a mitzvah to drink wine. These times are: A wedding meal (Even Ha’ezer 42), a Chanukas Habayis (inauguration of a new home, Magen Avrohom 568), a Seudas Hodaah (Orech Chaim 219), a Bris Milah (Yoreh Deah 265), Kiddush (Orech Chaim 271), Havdalah (Orech Chaim 296), Purim (Orech Chaim 695), and a...