Luigi is an ordinary Italian name. Why Nintendo gave it to Mario's brother has never been settled.
Luigi first appeared in Mario Bros., a 1983 platform game. He was designed as a palette swap of Mario: the same figure with a green color scheme. Wikipedia's article on him says plainly that it is unconfirmed how he got his name, though there are many theories.
The best-known theory involves a pizzeria. In a 2007 history of the series, Rus McLaughlin of IGN reported that the theories included a pizza parlor called Mario & Luigi's near the office of Minoru Arakawa. He also mentioned a rhyme with a Japanese word for "analogous."
The second theory is a pun. In 1986 the New Straits Times reported that Shigeru Miyamoto had observed that the Japanese word ruiji means "similar." That fits a character who began as Mario in a different color. Japanese dictionaries give ruiji as resemblance or similarity. The Japanese spelling of Luigi, ルイージ, is read Ruīji, so the two sound close.
The theories are not exclusive. A team could pick an Italian name that also made a joke in Japanese. No source shows which idea came first.
Mario's name has a clearer story. The usual account, repeated by Den of Geek, is that he was named after Mario Segale. Segale owned a warehouse in Tukwila, Washington, and barged in demanding overdue rent. In 2015 Miyamoto confirmed that the brothers share the surname Mario, which makes the younger one Luigi Mario.
The name itself is old. Luigi is the Italian form of the German Ludwig, through the Latin Ludovicus, and matches French Louis and English Lewis. Wikipedia glosses its meaning as "renowned" or "famous warrior." Behind the Name lists cousins across Europe, including Ludwig, Luis, Aloysius and Lajos.
Japanese puns run through the family's rivals too. Wario combines Mario with warui, "bad," and the W on his cap is an upside-down M. Waluigi uses the same warui with Luigi. Designer Shugo Takahashi told Nintendo Dream that, as a bad Luigi, he became Waluigi.